diff options
Diffstat (limited to 'libodb/odb/details/meta')
-rw-r--r-- | libodb/odb/details/meta/answer.hxx | 30 | ||||
-rw-r--r-- | libodb/odb/details/meta/class-p.hxx | 34 | ||||
-rw-r--r-- | libodb/odb/details/meta/polymorphic-p.hxx | 57 | ||||
-rw-r--r-- | libodb/odb/details/meta/remove-const-volatile.hxx | 31 | ||||
-rw-r--r-- | libodb/odb/details/meta/remove-const.hxx | 32 | ||||
-rw-r--r-- | libodb/odb/details/meta/remove-pointer.hxx | 32 | ||||
-rw-r--r-- | libodb/odb/details/meta/remove-volatile.hxx | 32 | ||||
-rw-r--r-- | libodb/odb/details/meta/static-assert.hxx | 32 |
8 files changed, 280 insertions, 0 deletions
diff --git a/libodb/odb/details/meta/answer.hxx b/libodb/odb/details/meta/answer.hxx new file mode 100644 index 0000000..f15dc43 --- /dev/null +++ b/libodb/odb/details/meta/answer.hxx @@ -0,0 +1,30 @@ +// file : odb/details/meta/answer.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_ANSWER_HXX +#define ODB_DETAILS_META_ANSWER_HXX + +#include <odb/pre.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + struct yes + { + char filling; + }; + + struct no + { + char filling[2]; + }; + } + } +} + +#include <odb/post.hxx> + +#endif // ODB_DETAILS_META_ANSWER_HXX diff --git a/libodb/odb/details/meta/class-p.hxx b/libodb/odb/details/meta/class-p.hxx new file mode 100644 index 0000000..bddb452 --- /dev/null +++ b/libodb/odb/details/meta/class-p.hxx @@ -0,0 +1,34 @@ +// file : odb/details/meta/class-p.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_CLASS_HXX +#define ODB_DETAILS_META_CLASS_HXX + +#include <odb/pre.hxx> + +#include <odb/details/meta/answer.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + // g++ cannot have these inside class_p. + // + template <typename X> no class_p_test (...); + template <typename X> yes class_p_test (void (X::*) ()); + + template <typename X> + struct class_p + { + static const bool result = + sizeof (class_p_test<X> (0)) == sizeof (yes); + }; + } + } +} + +#include <odb/post.hxx> + +#endif // ODB_DETAILS_META_CLASS_HXX diff --git a/libodb/odb/details/meta/polymorphic-p.hxx b/libodb/odb/details/meta/polymorphic-p.hxx new file mode 100644 index 0000000..10fef6a --- /dev/null +++ b/libodb/odb/details/meta/polymorphic-p.hxx @@ -0,0 +1,57 @@ +// file : odb/details/meta/polymorphic-p.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_POLYMORPHIC_HXX +#define ODB_DETAILS_META_POLYMORPHIC_HXX + +#include <odb/pre.hxx> + +#include <odb/details/config.hxx> // ODB_NOTHROW_NOEXCEPT +#include <odb/details/meta/class-p.hxx> +#include <odb/details/meta/remove-const-volatile.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename CVX> + struct polymorphic_p + { + typedef typename remove_const_volatile<CVX>::result X; + + template <typename Y, bool C> + struct impl + { + static const bool result = false; + }; + + template <typename Y> + struct impl<Y, true> + { + struct t1: Y + { + t1 (); + }; + + struct t2: Y + { + t2 (); + + virtual + ~t2 () ODB_NOTHROW_NOEXCEPT; + }; + + static const bool result = sizeof (t1) == sizeof (t2); + }; + + static const bool result = impl<X, class_p<X>::result>::result; + }; + } + } +} + +#include <odb/post.hxx> + +#endif // ODB_DETAILS_META_POLYMORPHIC_HXX diff --git a/libodb/odb/details/meta/remove-const-volatile.hxx b/libodb/odb/details/meta/remove-const-volatile.hxx new file mode 100644 index 0000000..910ec35 --- /dev/null +++ b/libodb/odb/details/meta/remove-const-volatile.hxx @@ -0,0 +1,31 @@ +// file : odb/details/meta/remove-const-volatile.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_REMOVE_CONST_VOLATILE_HXX +#define ODB_DETAILS_META_REMOVE_CONST_VOLATILE_HXX + +#include <odb/pre.hxx> + +#include <odb/details/meta/remove-const.hxx> +#include <odb/details/meta/remove-volatile.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename X> + struct remove_const_volatile + { + typedef + typename remove_volatile<typename remove_const<X>::result>::result + result; + }; + } + } +} + +#include <odb/post.hxx> + +#endif // ODB_DETAILS_META_REMOVE_CONST_VOLATILE_HXX diff --git a/libodb/odb/details/meta/remove-const.hxx b/libodb/odb/details/meta/remove-const.hxx new file mode 100644 index 0000000..4a92ed3 --- /dev/null +++ b/libodb/odb/details/meta/remove-const.hxx @@ -0,0 +1,32 @@ +// file : odb/details/meta/remove-const.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_REMOVE_CONST_HXX +#define ODB_DETAILS_META_REMOVE_CONST_HXX + +#include <odb/pre.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename X> + struct remove_const + { + typedef X result; + }; + + template <typename X> + struct remove_const<const X> + { + typedef X result; + }; + } + } +} + +#include <odb/post.hxx> + +#endif // ODB_DETAILS_META_REMOVE_CONST_HXX diff --git a/libodb/odb/details/meta/remove-pointer.hxx b/libodb/odb/details/meta/remove-pointer.hxx new file mode 100644 index 0000000..9963fd7 --- /dev/null +++ b/libodb/odb/details/meta/remove-pointer.hxx @@ -0,0 +1,32 @@ +// file : odb/details/meta/remove-pointer.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_REMOVE_POINTER_HXX +#define ODB_DETAILS_META_REMOVE_POINTER_HXX + +#include <odb/pre.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename X> + struct remove_pointer + { + typedef X result; + }; + + template <typename X> + struct remove_pointer<X*> + { + typedef X result; + }; + } + } +} + +#include <odb/post.hxx> + +#endif // ODB_DETAILS_META_REMOVE_POINTER_HXX diff --git a/libodb/odb/details/meta/remove-volatile.hxx b/libodb/odb/details/meta/remove-volatile.hxx new file mode 100644 index 0000000..877e532 --- /dev/null +++ b/libodb/odb/details/meta/remove-volatile.hxx @@ -0,0 +1,32 @@ +// file : odb/details/meta/remove-volatile.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_REMOVE_VOLATILE_HXX +#define ODB_DETAILS_META_REMOVE_VOLATILE_HXX + +#include <odb/pre.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename X> + struct remove_volatile + { + typedef X result; + }; + + template <typename X> + struct remove_volatile<volatile X> + { + typedef X result; + }; + } + } +} + +#include <odb/post.hxx> + +#endif // ODB_DETAILS_META_REMOVE_VOLATILE_HXX diff --git a/libodb/odb/details/meta/static-assert.hxx b/libodb/odb/details/meta/static-assert.hxx new file mode 100644 index 0000000..a2cc81b --- /dev/null +++ b/libodb/odb/details/meta/static-assert.hxx @@ -0,0 +1,32 @@ +// file : odb/details/meta/static-assert.hxx +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_STATIC_ASSERT_HXX +#define ODB_DETAILS_META_STATIC_ASSERT_HXX + +#include <odb/pre.hxx> + +#include <odb/details/config.hxx> // ODB_CXX11 + +#ifndef ODB_CXX11 + +namespace odb +{ + namespace details + { + namespace meta + { + template <bool> + struct static_assert_test; + + template <> + struct static_assert_test<true> {}; + } + } +} + +#endif + +#include <odb/post.hxx> + +#endif // ODB_DETAILS_META_STATIC_ASSERT_HXX |