aboutsummaryrefslogtreecommitdiff
path: root/odb/meta
diff options
context:
space:
mode:
Diffstat (limited to 'odb/meta')
-rw-r--r--odb/meta/answer.hxx25
-rw-r--r--odb/meta/class-p.hxx28
-rw-r--r--odb/meta/polymorphic-p.hxx51
-rw-r--r--odb/meta/remove-c.hxx27
-rw-r--r--odb/meta/remove-cv.hxx24
-rw-r--r--odb/meta/remove-p.hxx27
-rw-r--r--odb/meta/remove-v.hxx27
7 files changed, 209 insertions, 0 deletions
diff --git a/odb/meta/answer.hxx b/odb/meta/answer.hxx
new file mode 100644
index 0000000..80a25e0
--- /dev/null
+++ b/odb/meta/answer.hxx
@@ -0,0 +1,25 @@
+// file : odb/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_META_ANSWER_HXX
+#define ODB_META_ANSWER_HXX
+
+namespace odb
+{
+ namespace meta
+ {
+ struct yes
+ {
+ char filling;
+ };
+
+ struct no
+ {
+ char filling[2];
+ };
+ }
+}
+
+#endif // ODB_META_ANSWER_HXX
diff --git a/odb/meta/class-p.hxx b/odb/meta/class-p.hxx
new file mode 100644
index 0000000..e3d15c9
--- /dev/null
+++ b/odb/meta/class-p.hxx
@@ -0,0 +1,28 @@
+// file : odb/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_META_CLASS_HXX
+#define ODB_META_CLASS_HXX
+
+#include <odb/meta/answer.hxx>
+
+namespace odb
+{
+ 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_META_CLASS_HXX
diff --git a/odb/meta/polymorphic-p.hxx b/odb/meta/polymorphic-p.hxx
new file mode 100644
index 0000000..571ef52
--- /dev/null
+++ b/odb/meta/polymorphic-p.hxx
@@ -0,0 +1,51 @@
+// file : odb/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_META_POLYMORPHIC_HXX
+#define ODB_META_POLYMORPHIC_HXX
+
+#include <odb/meta/class-p.hxx>
+#include <odb/meta/remove-cv.hxx>
+
+namespace odb
+{
+ 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_META_POLYMORPHIC_HXX
diff --git a/odb/meta/remove-c.hxx b/odb/meta/remove-c.hxx
new file mode 100644
index 0000000..db724b3
--- /dev/null
+++ b/odb/meta/remove-c.hxx
@@ -0,0 +1,27 @@
+// file : odb/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_META_REMOVE_C_HXX
+#define ODB_META_REMOVE_C_HXX
+
+namespace odb
+{
+ namespace meta
+ {
+ template <typename X>
+ struct remove_c
+ {
+ typedef X r;
+ };
+
+ template <typename X>
+ struct remove_c<X const>
+ {
+ typedef X r;
+ };
+ }
+}
+
+#endif // ODB_META_REMOVE_C_HXX
diff --git a/odb/meta/remove-cv.hxx b/odb/meta/remove-cv.hxx
new file mode 100644
index 0000000..0805a9d
--- /dev/null
+++ b/odb/meta/remove-cv.hxx
@@ -0,0 +1,24 @@
+// file : odb/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_META_REMOVE_CV_HXX
+#define ODB_META_REMOVE_CV_HXX
+
+#include <odb/meta/remove-c.hxx>
+#include <odb/meta/remove-v.hxx>
+
+namespace odb
+{
+ namespace meta
+ {
+ template <typename X>
+ struct remove_cv
+ {
+ typedef typename remove_v<typename remove_c<X>::r>::r r;
+ };
+ }
+}
+
+#endif // ODB_META_REMOVE_CV_HXX
diff --git a/odb/meta/remove-p.hxx b/odb/meta/remove-p.hxx
new file mode 100644
index 0000000..053c860
--- /dev/null
+++ b/odb/meta/remove-p.hxx
@@ -0,0 +1,27 @@
+// file : odb/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_META_REMOVE_P_HXX
+#define ODB_META_REMOVE_P_HXX
+
+namespace odb
+{
+ namespace meta
+ {
+ template <typename X>
+ struct remove_p
+ {
+ typedef X r;
+ };
+
+ template <typename X>
+ struct remove_p<X*>
+ {
+ typedef X r;
+ };
+ }
+}
+
+#endif // ODB_META_REMOVE_P_HXX
diff --git a/odb/meta/remove-v.hxx b/odb/meta/remove-v.hxx
new file mode 100644
index 0000000..9e37a6c
--- /dev/null
+++ b/odb/meta/remove-v.hxx
@@ -0,0 +1,27 @@
+// file : odb/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_META_REMOVE_V_HXX
+#define ODB_META_REMOVE_V_HXX
+
+namespace odb
+{
+ namespace meta
+ {
+ template <typename X>
+ struct remove_v
+ {
+ typedef X r;
+ };
+
+ template <typename X>
+ struct remove_v<X volatile>
+ {
+ typedef X r;
+ };
+ }
+}
+
+#endif // ODB_META_REMOVE_V_HXX