Mirror reflection library 0.5.13

mirror/meta_prog/traits.hpp

Go to the documentation of this file.
00001 
00011 #ifndef MIRROR_META_PROG_TRAITS_1011291729_HPP
00012 #define MIRROR_META_PROG_TRAITS_1011291729_HPP
00013 
00014 #include <mirror/meta_prog/forward_decl.hpp>
00015 
00016 MIRROR_NAMESPACE_BEGIN
00017 namespace mp {
00018 
00019 #ifdef MIRROR_DOCUMENTATION_ONLY
00020 
00021 template <typename T>
00022 struct is_range : BooleanConstant
00023 { };
00024 #else
00025 template <typename T>
00026 struct is_range : std::false_type
00027 { };
00028 
00029 template <typename ... P>
00030 struct is_range<range<P...> > : std::true_type
00031 { };
00032 #endif
00033 
00034 #define MIRROR_ASSERT_IS_A_RANGE(EXPR, NAME) \
00035     static_assert( \
00036         is_range<EXPR>::value, \
00037         #NAME " is not a Range expression." \
00038     )
00039 
00040 #define MIRROR_ASSERT_RETURNS_RANGE(X) \
00041     MIRROR_ASSERT_IS_A_RANGE(typename X::type, X)
00042 
00043 #define MIRROR_ASSERT_IS_A_RANGE_OR_A_META(OBJECT, EXPR, NAME) \
00044     static_assert( \
00045         mirror::mp::is_a< \
00046             EXPR, \
00047             typename mirror::meta_##OBJECT##_tag \
00048         >::value || is_range<EXPR>::value, \
00049         #NAME " is not a Range nor a Meta" \
00050         MIRROR_META_OBJECT_NICE_NAME_STR(OBJECT) \
00051         " expression" \
00052     )
00053 
00054 #define MIRROR_ASSERT_RETURNS_RANGE_OR_META(OBJECT, X) \
00055     MIRROR_ASSERT_IS_A_RANGE_OR_A_META(OBJECT, typename X::type, X)
00056 
00057 
00058 #ifdef MIRROR_DOCUMENTATION_ONLY
00059 
00060 template <typename T>
00061 struct is_optional : BooleanConstant
00062 { };
00063 #else
00064 template <typename T>
00065 struct is_optional : std::false_type
00066 { };
00067 
00068 template <typename T>
00069 struct is_optional<optional<T> > : std::true_type
00070 { };
00071 #endif
00072 
00073 #define MIRROR_ASSERT_IS_AN_OPTIONAL(EXPR, NAME) \
00074     static_assert( \
00075         is_optional<EXPR>::value, \
00076         #NAME " is not an Optional expression." \
00077     )
00078 
00079 #define MIRROR_ASSERT_RETURNS_OPTIONAL(X) \
00080     MIRROR_ASSERT_IS_AN_OPTIONAL(typename X::type, X)
00081 
00082 
00083 } // namespace mp
00084 MIRROR_NAMESPACE_END
00085 
00086 #endif //include guard
00087 

Copyright © 2006-2011 Matus Chochlik, University of Zilina, Zilina, Slovakia.
<matus.chochlik -at- fri.uniza.sk>
<chochlik -at -gmail.com>
Documentation generated on Fri Dec 16 2011 by Doxygen (version 1.7.3).
Important note: Although the 'boostified' version of Mirror uses the Boost C++ libraries Coding Guidelines and is implemented inside of the boost namespace, it IS NOT an officially reviewed and accepted Boost library. Mirror is being developed with the intention to be submitted for review for inclusion to the Boost C++ libraries.