aboutsummaryrefslogtreecommitdiff
path: root/cutl/meta
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2009-09-06 12:52:53 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2009-09-06 12:52:53 +0200
commitcb9ea47e7825b5073d4d645afb94f6326cb7cf4d (patch)
tree201c215b08df918924153a60520046c294438a6b /cutl/meta
Start the libcutl repository
Diffstat (limited to 'cutl/meta')
-rw-r--r--cutl/meta/answer.hxx25
-rw-r--r--cutl/meta/class-p.hxx27
-rw-r--r--cutl/meta/polymorphic-p.hxx51
-rw-r--r--cutl/meta/remove-c.hxx27
-rw-r--r--cutl/meta/remove-cv.hxx24
-rw-r--r--cutl/meta/remove-p.hxx27
-rw-r--r--cutl/meta/remove-v.hxx27
7 files changed, 208 insertions, 0 deletions
diff --git a/cutl/meta/answer.hxx b/cutl/meta/answer.hxx
new file mode 100644
index 0000000..f476dd7
--- /dev/null
+++ b/cutl/meta/answer.hxx
@@ -0,0 +1,25 @@
+// file : cutl/meta/answer.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CUTL_META_ANSWER_HXX
+#define CUTL_META_ANSWER_HXX
+
+namespace cutl
+{
+ namespace meta
+ {
+ struct yes
+ {
+ char filling;
+ };
+
+ struct no
+ {
+ char filling[2];
+ };
+ }
+}
+
+#endif // CUTL_META_ANSWER_HXX
diff --git a/cutl/meta/class-p.hxx b/cutl/meta/class-p.hxx
new file mode 100644
index 0000000..79e8469
--- /dev/null
+++ b/cutl/meta/class-p.hxx
@@ -0,0 +1,27 @@
+// file : cutl/meta/class-p.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CUTL_META_CLASS_HXX
+#define CUTL_META_CLASS_HXX
+
+#include <cutl/meta/answer.hxx>
+
+namespace cutl
+{
+ namespace meta
+ {
+ template <typename X>
+ struct class_p
+ {
+ template <typename Y> static no test (...);
+ template <typename Y> static yes test (void* Y::*);
+
+ static bool const r = sizeof (
+ class_p<X>::template test<X> (0)) == sizeof (yes);
+ };
+ }
+}
+
+#endif // CUTL_META_CLASS_HXX
diff --git a/cutl/meta/polymorphic-p.hxx b/cutl/meta/polymorphic-p.hxx
new file mode 100644
index 0000000..35723e3
--- /dev/null
+++ b/cutl/meta/polymorphic-p.hxx
@@ -0,0 +1,51 @@
+// file : cutl/meta/polymorphic-p.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CUTL_META_POLYMORPHIC_HXX
+#define CUTL_META_POLYMORPHIC_HXX
+
+#include <cutl/meta/class-p.hxx>
+#include <cutl/meta/remove-cv.hxx>
+
+namespace cutl
+{
+ 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 // CUTL_META_POLYMORPHIC_HXX
diff --git a/cutl/meta/remove-c.hxx b/cutl/meta/remove-c.hxx
new file mode 100644
index 0000000..be7b8a6
--- /dev/null
+++ b/cutl/meta/remove-c.hxx
@@ -0,0 +1,27 @@
+// file : cutl/meta/remove-c.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CUTL_META_REMOVE_C_HXX
+#define CUTL_META_REMOVE_C_HXX
+
+namespace cutl
+{
+ namespace meta
+ {
+ template <typename X>
+ struct remove_c
+ {
+ typedef X r;
+ };
+
+ template <typename X>
+ struct remove_c<X const>
+ {
+ typedef X r;
+ };
+ }
+}
+
+#endif // CUTL_META_REMOVE_C_HXX
diff --git a/cutl/meta/remove-cv.hxx b/cutl/meta/remove-cv.hxx
new file mode 100644
index 0000000..5a7de7a
--- /dev/null
+++ b/cutl/meta/remove-cv.hxx
@@ -0,0 +1,24 @@
+// file : cutl/meta/remove-cv.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CUTL_META_REMOVE_CV_HXX
+#define CUTL_META_REMOVE_CV_HXX
+
+#include <cutl/meta/remove-c.hxx>
+#include <cutl/meta/remove-v.hxx>
+
+namespace cutl
+{
+ namespace meta
+ {
+ template <typename X>
+ struct remove_cv
+ {
+ typedef typename remove_v<typename remove_c<X>::r>::r r;
+ };
+ }
+}
+
+#endif // CUTL_META_REMOVE_CV_HXX
diff --git a/cutl/meta/remove-p.hxx b/cutl/meta/remove-p.hxx
new file mode 100644
index 0000000..56c4517
--- /dev/null
+++ b/cutl/meta/remove-p.hxx
@@ -0,0 +1,27 @@
+// file : cutl/meta/remove-p.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CUTL_META_REMOVE_P_HXX
+#define CUTL_META_REMOVE_P_HXX
+
+namespace cutl
+{
+ namespace meta
+ {
+ template <typename X>
+ struct remove_p
+ {
+ typedef X r;
+ };
+
+ template <typename X>
+ struct remove_p<X*>
+ {
+ typedef X r;
+ };
+ }
+}
+
+#endif // CUTL_META_REMOVE_P_HXX
diff --git a/cutl/meta/remove-v.hxx b/cutl/meta/remove-v.hxx
new file mode 100644
index 0000000..9f2ae46
--- /dev/null
+++ b/cutl/meta/remove-v.hxx
@@ -0,0 +1,27 @@
+// file : cutl/meta/remove-v.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009 Code Synthesis Tools CC
+// license : MIT; see accompanying LICENSE file
+
+#ifndef CUTL_META_REMOVE_V_HXX
+#define CUTL_META_REMOVE_V_HXX
+
+namespace cutl
+{
+ namespace meta
+ {
+ template <typename X>
+ struct remove_v
+ {
+ typedef X r;
+ };
+
+ template <typename X>
+ struct remove_v<X volatile>
+ {
+ typedef X r;
+ };
+ }
+}
+
+#endif // CUTL_META_REMOVE_V_HXX