summaryrefslogtreecommitdiff
path: root/boost/type_erasure/typeid_of.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'boost/type_erasure/typeid_of.hpp')
-rw-r--r--boost/type_erasure/typeid_of.hpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/boost/type_erasure/typeid_of.hpp b/boost/type_erasure/typeid_of.hpp
new file mode 100644
index 0000000000..5606883c6b
--- /dev/null
+++ b/boost/type_erasure/typeid_of.hpp
@@ -0,0 +1,70 @@
+// Boost.TypeErasure library
+//
+// Copyright 2011 Steven Watanabe
+//
+// Distributed under the Boost Software License Version 1.0. (See
+// accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+//
+// $Id$
+
+#ifndef BOOST_TYPE_ERASURE_TYPEID_OF_HPP_INCLUDED
+#define BOOST_TYPE_ERASURE_TYPEID_OF_HPP_INCLUDED
+
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/type_erasure/detail/access.hpp>
+#include <boost/type_erasure/any.hpp>
+#include <boost/type_erasure/binding.hpp>
+
+namespace boost {
+namespace type_erasure {
+
+/**
+ * The first form returns the type currently stored in an @ref any.
+ *
+ * The second form returns the type corresponding to a
+ * placeholder in @c binding.
+ *
+ * \pre @c Concept includes @ref typeid_ "typeid_<T>".
+ * \pre @c T is a non-reference, CV-unqualified @ref placeholder.
+ */
+template<class Concept, class T>
+const std::type_info& typeid_of(const any<Concept, T>& arg)
+{
+ return ::boost::type_erasure::detail::access::table(arg).template find<
+ ::boost::type_erasure::typeid_<
+ typename ::boost::remove_cv<
+ typename ::boost::remove_reference<T>::type
+ >::type
+ >
+ >()();
+}
+
+#ifndef BOOST_TYPE_ERASURE_DOXYGEN
+template<class Concept, class T>
+const std::type_info& typeid_of(const param<Concept, T>& arg)
+{
+ return ::boost::type_erasure::detail::access::table(arg).template find<
+ ::boost::type_erasure::typeid_<
+ typename ::boost::remove_cv<
+ typename ::boost::remove_reference<T>::type
+ >::type
+ >
+ >()();
+}
+#endif
+
+/**
+ * \overload
+ */
+template<class T, class Concept>
+const std::type_info& typeid_of(const binding<Concept>& binding_arg)
+{
+ return binding_arg.template find< ::boost::type_erasure::typeid_<T> >()();
+}
+
+}
+}
+
+#endif