File: testIsSame.cc

package info (click to toggle)
clhep 2.1.4.1%2Bdfsg-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 10,012 kB
  • sloc: cpp: 50,094; sh: 6,694; makefile: 2,694; perl: 28
file content (50 lines) | stat: -rw-r--r-- 1,367 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// ======================================================================
//
// Test basic functionality of is_same type trait
//
// Author:  W. E. Brown, 2010-03-24, adapted from the boost library's
// type_traits and related functionality whose internal attributions bear
// the following various notices:
//
//   (C) Copyright John Maddock 2000.
//   Distributed under the Boost Software License, Version 1.0.
//   See http://www.boost.org/LICENSE_1_0.txt
//
// ======================================================================


#include "CLHEP/Utility/type_traits.h"

#include <cassert>


using namespace CLHEP;
using CLHEP::is_same;


typedef  int  my_int;


#define claim_same(From,To)         (is_same<From,To>::value)
#define has_same_type(From,To)      assert(claim_same(From,To))
#define has_different_type(From,To) assert(!claim_same(From,To))


int main()
{
  has_same_type(int, int);
  has_same_type(int, my_int);

  has_different_type(int      , void);
  has_different_type(int      , const int);
  has_different_type(int      , int&);
  has_different_type(const int, int&);
  has_different_type(int      , const int&);
  has_different_type(int*     , const int*);
  has_different_type(int*     , int*const);
  has_different_type(int      , int[2]);
  has_different_type(int*     , int[2]);
  has_different_type(int[4]   , int[2]);

  return 0;
}