00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef VCSN_MISC_CONSTRAINTS_HH
00018 # define VCSN_MISC_CONSTRAINTS_HH
00019
00020
00021 namespace vcsn
00022 {
00023 namespace misc
00024 {
00025
00026
00027
00028
00029
00030
00031
00032
00033 # if defined(__GNUC__)
00034 # define UnusedConceptVar __attribute__ ((__unused__))
00035 # else
00036 # define UnusedConceptVar
00037 # endif
00038
00039 namespace concepts
00040 {
00041 template <typename Concept_>
00042 static void function_requires()
00043 {
00044 void (Concept_::*ptr)() UnusedConceptVar = &Concept_::constraints;
00045 }
00046
00047
00048
00049 # define MISC_CLASS_CHECKING_IDX(Lineno, Concept, T) \
00050 ConceptChecking ## Lineno ## _ ## Concept ## T
00051 # define MISC_CLASS_CHECKING_ID(Lineno, Concept, T) \
00052 MISC_CLASS_CHECKING_IDX(Lineno, Concept, T)
00053 # define MISC_CLASS_FPTR_IDX(Lineno, Concept, T) \
00054 Concept ## Lineno ## _fptr_ ## T
00055 # define MISC_CLASS_FPTR_ID(Lineno, Concept, T) \
00056 MISC_CLASS_FPTR_IDX(Lineno, Concept, T)
00057
00058 # ifdef VCSN_NDEBUG
00059
00060 # define MISC_CLASS_REQUIRE_CONCEPT(Var, Namespace, Concept) \
00061 typedef void MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00062 # define MISC_CLASS_REQUIRE_CONCEPT2(Var1, Var2, Namespace, Concept) \
00063 typedef void MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00064 # define MISC_CLASS_REQUIRE_CONCEPT3(Var1, Var2, Var3, Namespace, Concept) \
00065 typedef void MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00066 # define MISC_CLASS_REQUIRE_CONCEPT4(Var1, Var2, Var3, Var4, Namespace, Concept) \
00067 typedef void MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00068 # define MISC_REQUIRE_CONCEPT(Var, Namespace, Concept) \
00069 typedef void MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00070 # define MISC_REQUIRE_CONCEPT2(Var1, Var2, Namespace, Concept) \
00071 typedef void MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00072 # define MISC_REQUIRE_CONCEPT3(Var1, Var2, Var3, Namespace, Concept) \
00073 typedef void MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00074 # define MISC_REQUIRE_CONCEPT4(Var1, Var2, Var3, Var4, Namespace, Concept) \
00075 typedef void MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00076
00077 # else // VCSN_NDEBUG
00078
00079
00080
00081 # define MISC_CLASS_REQUIRE_CONCEPT(Var, Namespace, Concept) \
00082 typedef void (Namespace::Concept <Var>::* MISC_CLASS_FPTR_ID(__LINE__, Concept, t))(); \
00083 template <MISC_CLASS_FPTR_ID(__LINE__, Concept, t) MISC_CLASS_FPTR_ID(__LINE__, Concept, arg)> \
00084 struct MISC_CLASS_CHECKING_ID(__LINE__, Concept, _s) {}; \
00085 typedef MISC_CLASS_CHECKING_ID(__LINE__, Concept, _s)<& Namespace::Concept<Var>::constraints> \
00086 MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00087
00088 # define MISC_CLASS_REQUIRE_CONCEPT2(Var1, Var2, Namespace, Concept) \
00089 typedef void (Namespace::Concept <Var1,Var2>::* MISC_CLASS_FPTR_ID(__LINE__, Concept, t))(); \
00090 template <MISC_CLASS_FPTR_ID(__LINE__, Concept, t) MISC_CLASS_FPTR_ID(__LINE__, Concept, arg)> \
00091 struct MISC_CLASS_CHECKING_ID(__LINE__, Concept, _s) {}; \
00092 typedef MISC_CLASS_CHECKING_ID(__LINE__, Concept, _s)<& Namespace::Concept<Var1,Var2>::constraints> \
00093 MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00094
00095 # define MISC_CLASS_REQUIRE_CONCEPT3(Var1, Var2, Var3, Namespace, Concept) \
00096 typedef void (Namespace::Concept <Var1,Var2,Var3>::* MISC_CLASS_FPTR_ID(__LINE__, Concept, t))(); \
00097 template <MISC_CLASS_FPTR_ID(__LINE__, Concept, t) MISC_CLASS_FPTR_ID(__LINE__, Concept, arg)> \
00098 struct MISC_CLASS_CHECKING_ID(__LINE__, Concept, _s) {}; \
00099 typedef MISC_CLASS_CHECKING_ID(__LINE__, Concept, _s)<& Namespace::Concept<Var1,Var2,Var3>::constraints> \
00100 MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00101
00102 # define MISC_CLASS_REQUIRE_CONCEPT4(Var1, Var2, Var3, Var4, Namespace, Concept) \
00103 typedef void (Namespace::Concept <Var1,Var2,Var3,Var4>::* MISC_CLASS_FPTR_ID(__LINE__, Concept, t))(); \
00104 template <MISC_CLASS_FPTR_ID(__LINE__, Concept, t) MISC_CLASS_FPTR_ID(__LINE__, Concept, arg)> \
00105 struct MISC_CLASS_CHECKING_ID(__LINE__, Concept, _s) {}; \
00106 typedef MISC_CLASS_CHECKING_ID(__LINE__, Concept, _s)<& Namespace::Concept<Var1,Var2,Var3,Var4>::constraints> \
00107 MISC_CLASS_CHECKING_ID(__LINE__, Concept, _t)
00108
00109 # define MISC_REQUIRE_CONCEPT(Var, Namespace, Concept) \
00110 vcsn::misc::concepts::function_requires<Namespace::Concept <Var> >()
00111 # define MISC_REQUIRE_CONCEPT2(Var1, Var2, Namespace, Concept) \
00112 vcsn::misc::concepts::function_requires<Namespace::Concept <Var1, Var2> >()
00113 # define MISC_REQUIRE_CONCEPT3(Var1, Var2, Var3, Namespace, Concept) \
00114 vcsn::misc::concepts::function_requires<Namespace::Concept <Var1, Var2, Var3> >()
00115 # define MISC_REQUIRE_CONCEPT4(Var1, Var2, Var3, Var4, Namespace, Concept) \
00116 vcsn::misc::concepts::function_requires<Namespace::Concept <Var1, Var2, Var3, Var4> >()
00117
00118 # endif // ! VCSN_NDEBUG
00119
00120 }
00121 }
00122 }
00123
00124 #endif // ! VCSN_MISC_CONSTRAINTS_HH