$include_dir="/home/hyper-archives/boost-commit/include"; include("$include_dir/msg-header.inc") ?>
Subject: [Boost-commit] svn:boost r50709 - in trunk/boost/flyweight: . detail
From: joaquin_at_[hidden]
Date: 2009-01-21 14:52:03
Author: joaquin
Date: 2009-01-21 14:52:01 EST (Wed, 21 Jan 2009)
New Revision: 50709
URL: http://svn.boost.org/trac/boost/changeset/50709
Log:
reverted rev. 50283
prevented assoc_container_factory_class<Container> from instantiating Container when this type is an MPL placeholder expression
Added:
   trunk/boost/flyweight/detail/is_placeholder_expr.hpp   (contents, props changed)
   trunk/boost/flyweight/detail/nested_xxx_if_not_ph.hpp   (contents, props changed)
Text files modified: 
   trunk/boost/flyweight/assoc_container_factory.hpp |    35 +++++++++++++++++++++--------------     
   trunk/boost/flyweight/hashed_factory.hpp          |    16 +---------------                        
   trunk/boost/flyweight/intermodule_holder.hpp      |    12 +-----------                            
   trunk/boost/flyweight/set_factory.hpp             |    16 +---------------                        
   trunk/boost/flyweight/static_holder.hpp           |    12 +-----------                            
   5 files changed, 25 insertions(+), 66 deletions(-)
Modified: trunk/boost/flyweight/assoc_container_factory.hpp
==============================================================================
--- trunk/boost/flyweight/assoc_container_factory.hpp	(original)
+++ trunk/boost/flyweight/assoc_container_factory.hpp	2009-01-21 14:52:01 EST (Wed, 21 Jan 2009)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2008 Joaquin M Lopez Munoz.
+/* Copyright 2006-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -15,10 +15,16 @@
 
 #include <boost/config.hpp> /* keep it first to prevent nasty warns in MSVC */
 #include <boost/flyweight/assoc_container_factory_fwd.hpp>
+#include <boost/flyweight/detail/nested_xxx_if_not_ph.hpp>
 #include <boost/flyweight/factory_tag.hpp>
 #include <boost/mpl/apply.hpp>
 #include <boost/mpl/aux_/lambda_support.hpp>
 
+namespace boost{namespace flyweights{namespace detail{
+BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(iterator);
+BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(value_type);
+}}} /* namespace boost::flyweights::detail */
+
 /* Factory class using a given associative container.
  */
 
@@ -30,8 +36,20 @@
 class assoc_container_factory_class:public factory_marker
 {
 public:
-  typedef typename Container::iterator   handle_type;
-  typedef typename Container::value_type entry_type;
+
+  /* When assoc_container_factory_class<Container> is an MPL placeholder
+   * expression, referring to Container::iterator and Container::value_type
+   * force the MPL placeholder expression Container to be instantiated, which
+   * is wasteful and can fail in concept-checked STL implementations.
+   * We protect ourselves against this circumstance.
+   */
+
+  typedef typename detail::nested_iterator_if_not_placeholder_expression<
+    Container
+  >::type                                handle_type;
+  typedef typename detail::nested_value_type_if_not_placeholder_expression<
+    Container
+  >::type                                entry_type;
   
   handle_type insert(const entry_type& x)
   {
@@ -53,17 +71,6 @@
   BOOST_MPL_AUX_LAMBDA_SUPPORT(1,assoc_container_factory_class,(Container))
 };
 
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
-/* This is preferred to deriving from factory_marker since checking for
- * derivation forces the instantiation of the specifier, which is not
- * needed when the specifier is a placeholder expression.
- */
-
-template<typename Container>
-struct is_factory<assoc_container_factory_class<Container> >:
-  boost::mpl::true_{};
-#endif
-
 /* assoc_container_factory_class specifier */
 
 template<
Added: trunk/boost/flyweight/detail/is_placeholder_expr.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/flyweight/detail/is_placeholder_expr.hpp	2009-01-21 14:52:01 EST (Wed, 21 Jan 2009)
@@ -0,0 +1,65 @@
+/* Copyright 2006-2009 Joaquin M Lopez Munoz.
+ * 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_IS_PLACEHOLDER_EXPR_HPP
+#define BOOST_FLYWEIGHT_DETAIL_IS_PLACEHOLDER_EXPR_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/type_traits/is_same.hpp>
+#include <boost/mpl/apply.hpp>
+#include <boost/mpl/aux_/lambda_support.hpp>
+#include <boost/mpl/not.hpp>
+#include <boost/preprocessor/facilities/intercept.hpp>
+#include <boost/preprocessor/repetition/enum_params.hpp>
+
+namespace boost{
+
+namespace flyweights{
+
+namespace detail{
+
+/* is_placeholder_expression<T> indicates whether T is an
+ * MPL placeholder expression.
+ */
+
+template<typename T>
+struct is_placeholder_expression_helper
+{
+  template<
+    BOOST_PP_ENUM_PARAMS(
+      BOOST_MPL_LIMIT_METAFUNCTION_ARITY,typename BOOST_PP_INTERCEPT)
+  >
+  struct apply{
+    typedef int type;
+  };
+
+  BOOST_MPL_AUX_LAMBDA_SUPPORT(1,is_placeholder_expression_helper,(T))
+};
+
+template<typename T>
+struct is_placeholder_expression:
+  mpl::not_<is_same<
+    typename mpl::apply<
+      is_placeholder_expression_helper<T>,
+      BOOST_PP_ENUM_PARAMS(
+        BOOST_MPL_LIMIT_METAFUNCTION_ARITY,int BOOST_PP_INTERCEPT)
+    >::type,
+    int
+  > >
+{};
+
+} /* namespace flyweights::detail */
+
+} /* namespace flyweights */
+
+} /* namespace boost */
+
+#endif
Added: trunk/boost/flyweight/detail/nested_xxx_if_not_ph.hpp
==============================================================================
--- (empty file)
+++ trunk/boost/flyweight/detail/nested_xxx_if_not_ph.hpp	2009-01-21 14:52:01 EST (Wed, 21 Jan 2009)
@@ -0,0 +1,39 @@
+/* Copyright 2006-2009 Joaquin M Lopez Munoz.
+ * 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)
+ *
+ * See http://www.boost.org/libs/flyweight for library home page.
+ */
+
+#ifndef BOOST_FLYWEIGHT_DETAIL_NESTED_XXX_IF_NOT_PH_HPP
+#define BOOST_FLYWEIGHT_DETAIL_NESTED_XXX_IF_NOT_PH_HPP
+
+#if defined(_MSC_VER)&&(_MSC_VER>=1200)
+#pragma once
+#endif
+
+#include <boost/flyweight/detail/is_placeholder_expr.hpp>
+#include <boost/mpl/if.hpp>
+
+/* nested_##name##_if_not_placeholder_expression<T>::type is T::name unless
+ * T is an MPL placeholder expression, in which case it defaults to int.
+ */
+
+#define BOOST_FLYWEIGHT_NESTED_XXX_IF_NOT_PLACEHOLDER_EXPRESSION_DEF(name) \
+struct nested_##name##_if_not_placeholder_expression_helper                \
+{                                                                          \
+  typedef int name;                                                        \
+};                                                                         \
+                                                                           \
+template<typename T>                                                       \
+struct nested_##name##_if_not_placeholder_expression                       \
+{                                                                          \
+  typedef typename boost::mpl::if_<                                        \
+    boost::flyweights::detail::is_placeholder_expression<T>,               \
+    nested_##name##_if_not_placeholder_expression_helper,                  \
+    T                                                                      \
+  >::type::name type;                                                      \
+};
+
+#endif
Modified: trunk/boost/flyweight/hashed_factory.hpp
==============================================================================
--- trunk/boost/flyweight/hashed_factory.hpp	(original)
+++ trunk/boost/flyweight/hashed_factory.hpp	2009-01-21 14:52:01 EST (Wed, 21 Jan 2009)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2008 Joaquin M Lopez Munoz.
+/* Copyright 2006-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -88,20 +88,6 @@
     5,hashed_factory_class,(Entry,Key,Hash,Pred,Allocator))
 };
 
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
-/* This is preferred to deriving from factory_marker since checking for
- * derivation forces the instantiation of the specifier, which is not
- * needed when the specifier is a placeholder expression.
- */
-
-template<
-  typename Entry,typename Key,
-  typename Hash,typename Pred,typename Allocator
->
-struct is_factory<hashed_factory_class<Entry,Key,Hash,Pred,Allocator> >:
-  boost::mpl::true_{};
-#endif
-
 /* hashed_factory_class specifier */
 
 template<
Modified: trunk/boost/flyweight/intermodule_holder.hpp
==============================================================================
--- trunk/boost/flyweight/intermodule_holder.hpp	(original)
+++ trunk/boost/flyweight/intermodule_holder.hpp	2009-01-21 14:52:01 EST (Wed, 21 Jan 2009)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2008 Joaquin M Lopez Munoz.
+/* Copyright 2006-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -174,16 +174,6 @@
   BOOST_MPL_AUX_LAMBDA_SUPPORT(1,intermodule_holder_class,(C))
 };
 
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
-/* This is preferred to deriving from holder_marker since checking for
- * derivation forces the instantiation of the specifier, which is not
- * needed when the specifier is a placeholder expression.
- */
-
-template<typename C>
-struct is_holder<intermodule_holder_class<C> >:boost::mpl::true_{};
-#endif
-
 /* intermodule_holder_class specifier */
 
 struct intermodule_holder:holder_marker
Modified: trunk/boost/flyweight/set_factory.hpp
==============================================================================
--- trunk/boost/flyweight/set_factory.hpp	(original)
+++ trunk/boost/flyweight/set_factory.hpp	2009-01-21 14:52:01 EST (Wed, 21 Jan 2009)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2008 Joaquin M Lopez Munoz.
+/* Copyright 2006-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -56,20 +56,6 @@
     4,set_factory_class,(Entry,Key,Compare,Allocator))
 };
 
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
-/* This is preferred to deriving from factory_marker since checking for
- * derivation forces the instantiation of the specifier, which is not
- * needed when the specifier is a placeholder expression.
- */
-
-template<
-  typename Entry,typename Key,
-  typename Compare,typename Allocator
->
-struct is_factory<set_factory_class<Entry,Key,Compare,Allocator> >:
-  boost::mpl::true_{};
-#endif
-
 /* set_factory_class specifier */
 
 template<
Modified: trunk/boost/flyweight/static_holder.hpp
==============================================================================
--- trunk/boost/flyweight/static_holder.hpp	(original)
+++ trunk/boost/flyweight/static_holder.hpp	2009-01-21 14:52:01 EST (Wed, 21 Jan 2009)
@@ -1,4 +1,4 @@
-/* Copyright 2006-2008 Joaquin M Lopez Munoz.
+/* Copyright 2006-2009 Joaquin M Lopez Munoz.
  * 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)
@@ -38,16 +38,6 @@
   BOOST_MPL_AUX_LAMBDA_SUPPORT(1,static_holder_class,(C))
 };
 
-#if !defined(BOOST_NO_TEMPLATE_PARTIAL_SPECIALIZATION)
-/* This is preferred to deriving from holder_marker since checking for
- * derivation forces the instantiation of the specifier, which is not
- * needed when the specifier is a placeholder expression.
- */
-
-template<typename C>
-struct is_holder<static_holder_class<C> >:boost::mpl::true_{};
-#endif
-
 /* static_holder_class specifier */
 
 struct static_holder:holder_marker