check.hpp 895 Bytes
Newer Older
edwin.carlinet's avatar
edwin.carlinet committed
1
2
3
#ifndef MLN_CORE_CONCEPT_CHECK_HPP
# define MLN_CORE_CONCEPT_CHECK_HPP

edwin.carlinet's avatar
edwin.carlinet committed
4
5
6
# include <type_traits>
# include <string>

Edwin Carlinet's avatar
Edwin Carlinet committed
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
namespace internal
{
  template <bool cond, typename T>
  struct mln_check_if_
  {
    mln_check_if_() {}
  };

  template <typename T>
  struct mln_check_if_<true, T>
  {
    mln_check_if_() { ((T*)0)->~T(); }
  };
}

# define MLN_CONCEPT_BEGIN_CHECK_IF()					\
  {									\
  struct __mln_check_if__						\
  {									\
  ~__mln_check_if__()							\
  {									\


# define MLN_CONCEPT_END_CHECK_IF(TEST)			\
  }							\
    };							\
  internal::mln_check_if_<TEST, __mln_check_if__> ();	\
  }




edwin.carlinet's avatar
edwin.carlinet committed
39
40
41
42
43
44
45
46
47
48
49
namespace mln
{

  void check(std::true_type)
  {
  }

  void check(std::true_type, std::string)
  {
  }

edwin.carlinet's avatar
edwin.carlinet committed
50
51
52
53
54
55
56
57
  void check_false(std::false_type)
  {
  }

  void check_false(std::false_type, std::string)
  {
  }

edwin.carlinet's avatar
edwin.carlinet committed
58
59
60
61

} // end of namespace mln

#endif //!MLN_CORE_CONCEPT_CHECK_HPP