diff options
Diffstat (limited to 'odb/details/meta')
-rw-r--r-- | odb/details/meta/answer.hxx | 28 | ||||
-rw-r--r-- | odb/details/meta/class-p.hxx | 31 | ||||
-rw-r--r-- | odb/details/meta/polymorphic-p.hxx | 54 | ||||
-rw-r--r-- | odb/details/meta/remove-c.hxx | 30 | ||||
-rw-r--r-- | odb/details/meta/remove-cv.hxx | 27 | ||||
-rw-r--r-- | odb/details/meta/remove-p.hxx | 30 | ||||
-rw-r--r-- | odb/details/meta/remove-v.hxx | 30 |
7 files changed, 230 insertions, 0 deletions
diff --git a/odb/details/meta/answer.hxx b/odb/details/meta/answer.hxx new file mode 100644 index 0000000..31387a9 --- /dev/null +++ b/odb/details/meta/answer.hxx @@ -0,0 +1,28 @@ +// file : odb/details/meta/answer.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_ANSWER_HXX +#define ODB_DETAILS_META_ANSWER_HXX + +namespace odb +{ + namespace details + { + namespace meta + { + struct yes + { + char filling; + }; + + struct no + { + char filling[2]; + }; + } + } +} + +#endif // ODB_DETAILS_META_ANSWER_HXX diff --git a/odb/details/meta/class-p.hxx b/odb/details/meta/class-p.hxx new file mode 100644 index 0000000..c680d8e --- /dev/null +++ b/odb/details/meta/class-p.hxx @@ -0,0 +1,31 @@ +// file : odb/details/meta/class-p.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_CLASS_HXX +#define ODB_DETAILS_META_CLASS_HXX + +#include <odb/details/meta/answer.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + // g++ cannot have these inside class_p. + // + template <typename Y> no class_p_test (...); + template <typename Y> yes class_p_test (void (Y::*) ()); + + template <typename X> + struct class_p + { + static bool const r = sizeof (class_p_test<X> (0)) == sizeof (yes); + }; + } + } +} + +#endif // ODB_DETAILS_META_CLASS_HXX diff --git a/odb/details/meta/polymorphic-p.hxx b/odb/details/meta/polymorphic-p.hxx new file mode 100644 index 0000000..6e95144 --- /dev/null +++ b/odb/details/meta/polymorphic-p.hxx @@ -0,0 +1,54 @@ +// file : odb/details/meta/polymorphic-p.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_POLYMORPHIC_HXX +#define ODB_DETAILS_META_POLYMORPHIC_HXX + +#include <odb/details/meta/class-p.hxx> +#include <odb/details/meta/remove-cv.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename CVX> + struct polymorphic_p + { + typedef typename remove_cv<CVX>::r X; + + template <typename Y, bool C> + struct impl + { + static const bool r = false; + }; + + template <typename Y> + struct impl<Y, true> + { + struct t1: Y + { + t1 (); + }; + + struct t2: Y + { + t2 (); + + virtual + ~t2 () throw (); + }; + + static const bool r = sizeof (t1) == sizeof (t2); + }; + + static const bool r = impl<X, class_p<X>::r>::r; + }; + } + } +} + +#endif // ODB_DETAILS_META_POLYMORPHIC_HXX diff --git a/odb/details/meta/remove-c.hxx b/odb/details/meta/remove-c.hxx new file mode 100644 index 0000000..9d8e0b5 --- /dev/null +++ b/odb/details/meta/remove-c.hxx @@ -0,0 +1,30 @@ +// file : odb/details/meta/remove-c.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_REMOVE_C_HXX +#define ODB_DETAILS_META_REMOVE_C_HXX + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename X> + struct remove_c + { + typedef X r; + }; + + template <typename X> + struct remove_c<X const> + { + typedef X r; + }; + } + } +} + +#endif // ODB_DETAILS_META_REMOVE_C_HXX diff --git a/odb/details/meta/remove-cv.hxx b/odb/details/meta/remove-cv.hxx new file mode 100644 index 0000000..958fc08 --- /dev/null +++ b/odb/details/meta/remove-cv.hxx @@ -0,0 +1,27 @@ +// file : odb/details/meta/remove-cv.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_REMOVE_CV_HXX +#define ODB_DETAILS_META_REMOVE_CV_HXX + +#include <odb/details/meta/remove-c.hxx> +#include <odb/details/meta/remove-v.hxx> + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename X> + struct remove_cv + { + typedef typename remove_v<typename remove_c<X>::r>::r r; + }; + } + } +} + +#endif // ODB_DETAILS_META_REMOVE_CV_HXX diff --git a/odb/details/meta/remove-p.hxx b/odb/details/meta/remove-p.hxx new file mode 100644 index 0000000..c8f6d92 --- /dev/null +++ b/odb/details/meta/remove-p.hxx @@ -0,0 +1,30 @@ +// file : odb/details/meta/remove-p.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_REMOVE_P_HXX +#define ODB_DETAILS_META_REMOVE_P_HXX + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename X> + struct remove_p + { + typedef X r; + }; + + template <typename X> + struct remove_p<X*> + { + typedef X r; + }; + } + } +} + +#endif // ODB_DETAILS_META_REMOVE_P_HXX diff --git a/odb/details/meta/remove-v.hxx b/odb/details/meta/remove-v.hxx new file mode 100644 index 0000000..c91b7e4 --- /dev/null +++ b/odb/details/meta/remove-v.hxx @@ -0,0 +1,30 @@ +// file : odb/details/meta/remove-v.hxx +// author : Boris Kolpackov <boris@codesynthesis.com> +// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +#ifndef ODB_DETAILS_META_REMOVE_V_HXX +#define ODB_DETAILS_META_REMOVE_V_HXX + +namespace odb +{ + namespace details + { + namespace meta + { + template <typename X> + struct remove_v + { + typedef X r; + }; + + template <typename X> + struct remove_v<X volatile> + { + typedef X r; + }; + } + } +} + +#endif // ODB_DETAILS_META_REMOVE_V_HXX |