diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2025-03-19 15:41:36 +0100 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2025-03-19 15:41:36 +0100 |
commit | 018e1ba581ec6f01f069a45ec4cf89f152b44d5f (patch) | |
tree | 0e7dda4bb693a6714066fbe5efcd2f24ff7c1a65 /libcutl/cutl/meta | |
parent | 1c188393cd2e271ed2581471b601fb5960777fd8 (diff) |
remerge
Diffstat (limited to 'libcutl/cutl/meta')
-rw-r--r-- | libcutl/cutl/meta/answer.hxx | 24 | ||||
-rw-r--r-- | libcutl/cutl/meta/class-p.hxx | 27 | ||||
-rw-r--r-- | libcutl/cutl/meta/polymorphic-p.hxx | 50 | ||||
-rw-r--r-- | libcutl/cutl/meta/remove-c.hxx | 26 | ||||
-rw-r--r-- | libcutl/cutl/meta/remove-cv.hxx | 23 | ||||
-rw-r--r-- | libcutl/cutl/meta/remove-p.hxx | 26 | ||||
-rw-r--r-- | libcutl/cutl/meta/remove-v.hxx | 26 |
7 files changed, 202 insertions, 0 deletions
diff --git a/libcutl/cutl/meta/answer.hxx b/libcutl/cutl/meta/answer.hxx new file mode 100644 index 0000000..96a3911 --- /dev/null +++ b/libcutl/cutl/meta/answer.hxx @@ -0,0 +1,24 @@ +// file : cutl/meta/answer.hxx +// copyright : Copyright (c) 2009-2013 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/libcutl/cutl/meta/class-p.hxx b/libcutl/cutl/meta/class-p.hxx new file mode 100644 index 0000000..fec5a59 --- /dev/null +++ b/libcutl/cutl/meta/class-p.hxx @@ -0,0 +1,27 @@ +// file : cutl/meta/class-p.hxx +// copyright : Copyright (c) 2009-2013 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 + { + // 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 // CUTL_META_CLASS_HXX diff --git a/libcutl/cutl/meta/polymorphic-p.hxx b/libcutl/cutl/meta/polymorphic-p.hxx new file mode 100644 index 0000000..dd820db --- /dev/null +++ b/libcutl/cutl/meta/polymorphic-p.hxx @@ -0,0 +1,50 @@ +// file : cutl/meta/polymorphic-p.hxx +// copyright : Copyright (c) 2009-2013 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/libcutl/cutl/meta/remove-c.hxx b/libcutl/cutl/meta/remove-c.hxx new file mode 100644 index 0000000..0f67488 --- /dev/null +++ b/libcutl/cutl/meta/remove-c.hxx @@ -0,0 +1,26 @@ +// file : cutl/meta/remove-c.hxx +// copyright : Copyright (c) 2009-2013 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/libcutl/cutl/meta/remove-cv.hxx b/libcutl/cutl/meta/remove-cv.hxx new file mode 100644 index 0000000..1d825da --- /dev/null +++ b/libcutl/cutl/meta/remove-cv.hxx @@ -0,0 +1,23 @@ +// file : cutl/meta/remove-cv.hxx +// copyright : Copyright (c) 2009-2013 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/libcutl/cutl/meta/remove-p.hxx b/libcutl/cutl/meta/remove-p.hxx new file mode 100644 index 0000000..f032dc2 --- /dev/null +++ b/libcutl/cutl/meta/remove-p.hxx @@ -0,0 +1,26 @@ +// file : cutl/meta/remove-p.hxx +// copyright : Copyright (c) 2009-2013 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/libcutl/cutl/meta/remove-v.hxx b/libcutl/cutl/meta/remove-v.hxx new file mode 100644 index 0000000..ac05f28 --- /dev/null +++ b/libcutl/cutl/meta/remove-v.hxx @@ -0,0 +1,26 @@ +// file : cutl/meta/remove-v.hxx +// copyright : Copyright (c) 2009-2013 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 |