Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r80606 - in sandbox/type_erasure/boost/type_erasure: . detail
From: steven_at_[hidden]
Date: 2012-09-19 20:33:04


Author: steven_watanabe
Date: 2012-09-19 20:33:03 EDT (Wed, 19 Sep 2012)
New Revision: 80606
URL: http://svn.boost.org/trac/boost/changeset/80606

Log:
Initial work on better error messages.
Added:
   sandbox/type_erasure/boost/type_erasure/detail/instantiate.hpp (contents, props changed)
Text files modified:
   sandbox/type_erasure/boost/type_erasure/any.hpp | 6 ++++--
   sandbox/type_erasure/boost/type_erasure/binding.hpp | 5 +++--
   sandbox/type_erasure/boost/type_erasure/builtin.hpp | 10 ++++++++++
   3 files changed, 17 insertions(+), 4 deletions(-)

Modified: sandbox/type_erasure/boost/type_erasure/any.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/any.hpp (original)
+++ sandbox/type_erasure/boost/type_erasure/any.hpp 2012-09-19 20:33:03 EDT (Wed, 19 Sep 2012)
@@ -35,6 +35,7 @@
 #include <boost/type_erasure/detail/any_base.hpp>
 #include <boost/type_erasure/detail/normalize.hpp>
 #include <boost/type_erasure/detail/storage.hpp>
+#include <boost/type_erasure/detail/instantiate.hpp>
 #include <boost/type_erasure/config.hpp>
 #include <boost/type_erasure/binding.hpp>
 #include <boost/type_erasure/static_binding.hpp>
@@ -171,10 +172,11 @@
      */
     template<class U>
     explicit any(const U& data_arg)
- : table(
+ : table((::boost::type_erasure::detail::make_instantiate_concept<
+ Concept, ::boost::mpl::map< ::boost::mpl::pair<T, U> > >::type::apply(),
             ::boost::type_erasure::make_binding<
                 ::boost::mpl::map< ::boost::mpl::pair<T, U> >
- >()
+ >())
         ),
         data(data_arg)
     {}

Modified: sandbox/type_erasure/boost/type_erasure/binding.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/binding.hpp (original)
+++ sandbox/type_erasure/boost/type_erasure/binding.hpp 2012-09-19 20:33:03 EDT (Wed, 19 Sep 2012)
@@ -28,6 +28,7 @@
 #include <boost/type_erasure/detail/rebind_placeholders.hpp>
 #include <boost/type_erasure/detail/vtable.hpp>
 #include <boost/type_erasure/detail/normalize.hpp>
+#include <boost/type_erasure/detail/instantiate.hpp>
 
 namespace boost {
 namespace type_erasure {
@@ -88,7 +89,7 @@
      */
     template<class Map>
     explicit binding(const Map&)
- : impl(static_binding<Map>())
+ : impl((::boost::type_erasure::detail::make_instantiate_concept<Concept, Map>::type::apply(), static_binding<Map>()))
     {}
     
     /**
@@ -99,7 +100,7 @@
      */
     template<class Map>
     binding(const static_binding<Map>&)
- : impl(static_binding<Map>())
+ : impl((::boost::type_erasure::detail::make_instantiate_concept<Concept, Map>::type::apply(), static_binding<Map>()))
     {}
 
     /**

Modified: sandbox/type_erasure/boost/type_erasure/builtin.hpp
==============================================================================
--- sandbox/type_erasure/boost/type_erasure/builtin.hpp (original)
+++ sandbox/type_erasure/boost/type_erasure/builtin.hpp 2012-09-19 20:33:03 EDT (Wed, 19 Sep 2012)
@@ -40,6 +40,11 @@
     {
         delete static_cast<T*>(arg.data);
     }
+ /** INTERNAL ONLY */
+ static void apply(detail::storage& arg)
+ {
+ delete static_cast<T*>(arg.data);
+ }
 };
 
 /**
@@ -90,6 +95,11 @@
     {
         return typeid(T);
     }
+ /** INTERNAL ONLY */
+ static const std::type_info& apply()
+ {
+ return typeid(T);
+ }
 };
 
 namespace detail {

Added: sandbox/type_erasure/boost/type_erasure/detail/instantiate.hpp
==============================================================================
--- (empty file)
+++ sandbox/type_erasure/boost/type_erasure/detail/instantiate.hpp 2012-09-19 20:33:03 EDT (Wed, 19 Sep 2012)
@@ -0,0 +1,112 @@
+// Boost.TypeErasure library
+//
+// Copyright 2012 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$
+
+#if !defined(BOOST_PP_IS_ITERATING)
+
+#ifndef BOOST_TYPE_ERASURE_DETAIL_INSTANTIATE_HPP_INCLUDED
+#define BOOST_TYPE_ERASURE_DETAIL_INSTANTIATE_HPP_INCLUDED
+
+#include <boost/mpl/transform.hpp>
+#include <boost/mpl/size.hpp>
+#include <boost/mpl/at.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/repetition/repeat.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+#include <boost/type_erasure/detail/normalize.hpp>
+#include <boost/type_erasure/detail/rebind_placeholders.hpp>
+
+namespace boost {
+namespace type_erasure {
+namespace detail {
+
+template<int N>
+struct make_instantiate_concept_impl;
+
+template<class Concept, class Map>
+struct make_instantiate_concept {
+ typedef typename ::boost::type_erasure::detail::normalize_concept<
+ Concept>::type normalized;
+ typedef typename ::boost::type_erasure::detail::get_placeholder_normalization_map<
+ Concept
+ >::type placeholder_subs;
+
+ typedef typename ::boost::mpl::transform<
+ normalized,
+ ::boost::type_erasure::detail::rebind_placeholders<
+ ::boost::mpl::_1,
+ typename ::boost::type_erasure::detail::add_deductions<
+ Map,
+ placeholder_subs
+ >::type
+ >
+ >::type bound_concept;
+ typedef typename ::boost::type_erasure::detail::make_instantiate_concept_impl<
+ (::boost::mpl::size<bound_concept>::value)
+ >::template apply<bound_concept>::type type;
+};
+
+#define BOOST_PP_FILENAME_1 <boost/type_erasure/detail/instantiate.hpp>
+#define BOOST_PP_ITERATION_LIMITS (0, BOOST_TYPE_ERASURE_MAX_FUNCTIONS)
+#include BOOST_PP_ITERATE()
+
+}
+}
+}
+
+#endif
+
+#else
+
+#define N BOOST_PP_ITERATION()
+
+#define BOOST_TYPE_ERASURE_INSTANTIATE(z, n, data)\
+ (void)&BOOST_PP_CAT(T, n)::apply;
+
+#define BOOST_TYPE_ERASURE_AT(z, n, data) \
+ typename ::boost::mpl::at_c<data, n>::type
+
+#if N
+
+template<BOOST_PP_ENUM_PARAMS(N, class T)>
+struct BOOST_PP_CAT(instantiate_concept, N) {
+ static void apply() {
+ BOOST_PP_REPEAT(N, BOOST_TYPE_ERASURE_INSTANTIATE, ~)
+ }
+};
+
+#else
+
+template<class T = void>
+struct instantiate_concept0 {
+ static void apply() {}
+};
+
+#endif
+
+template<>
+struct make_instantiate_concept_impl<N>
+{
+ template<class Seq>
+ struct apply
+ {
+ typedef ::boost::type_erasure::detail::BOOST_PP_CAT(instantiate_concept, N)<
+ BOOST_PP_ENUM(N, BOOST_TYPE_ERASURE_AT, Seq)
+ > type;
+ };
+};
+
+#undef BOOST_TYPE_ERASURE_AT
+#undef BOOST_TYPE_ERASURE_INSTANTIATE
+
+#undef N
+
+#endif


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk