From 6f0d40508286afc8cdd72a0b5f807d5c2a589cfc Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 4 Jun 2010 16:33:08 +0200 Subject: Initial implementation --- odb/meta/answer.hxx | 25 +++++++++++++++++++++++ odb/meta/class-p.hxx | 28 +++++++++++++++++++++++++ odb/meta/polymorphic-p.hxx | 51 ++++++++++++++++++++++++++++++++++++++++++++++ odb/meta/remove-c.hxx | 27 ++++++++++++++++++++++++ odb/meta/remove-cv.hxx | 24 ++++++++++++++++++++++ odb/meta/remove-p.hxx | 27 ++++++++++++++++++++++++ odb/meta/remove-v.hxx | 27 ++++++++++++++++++++++++ 7 files changed, 209 insertions(+) create mode 100644 odb/meta/answer.hxx create mode 100644 odb/meta/class-p.hxx create mode 100644 odb/meta/polymorphic-p.hxx create mode 100644 odb/meta/remove-c.hxx create mode 100644 odb/meta/remove-cv.hxx create mode 100644 odb/meta/remove-p.hxx create mode 100644 odb/meta/remove-v.hxx (limited to 'odb/meta') 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 +// 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 +// 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 + +namespace odb +{ + namespace meta + { + // g++ cannot have these inside class_p. + // + template no class_p_test (...); + template yes class_p_test (void (Y::*) ()); + + template + struct class_p + { + static bool const r = sizeof (class_p_test (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 +// 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 +#include + +namespace odb +{ + namespace meta + { + template + struct polymorphic_p + { + typedef typename remove_cv::r X; + + template + struct impl + { + static const bool r = false; + }; + + template + struct impl + { + struct t1: Y + { + t1 (); + }; + + struct t2: Y + { + t2 (); + + virtual + ~t2 () throw (); + }; + + static const bool r = sizeof (t1) == sizeof (t2); + }; + + static const bool r = impl::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 +// 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 + struct remove_c + { + typedef X r; + }; + + template + struct remove_c + { + 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 +// 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 +#include + +namespace odb +{ + namespace meta + { + template + struct remove_cv + { + typedef typename remove_v::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 +// 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 + struct remove_p + { + typedef X r; + }; + + template + struct remove_p + { + 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 +// 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 + struct remove_v + { + typedef X r; + }; + + template + struct remove_v + { + typedef X r; + }; + } +} + +#endif // ODB_META_REMOVE_V_HXX -- cgit v1.1