Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r77046 - in trunk: boost/utility libs/utility
From: dwalker07_at_[hidden]
Date: 2012-02-16 20:55:34


Author: dlwalker
Date: 2012-02-16 20:55:33 EST (Thu, 16 Feb 2012)
New Revision: 77046
URL: http://svn.boost.org/trac/boost/changeset/77046

Log:
Fixed (hopefully) conflict between boost::base_from_member's C++11 constructor template and the automatically defined non-template copy- and/or move-constructors.
Text files modified:
   trunk/boost/utility/base_from_member.hpp | 64 ++++++++++++++++++++++++++++++++++++++-
   trunk/libs/utility/base_from_member.html | 24 ++++++++------
   2 files changed, 75 insertions(+), 13 deletions(-)

Modified: trunk/boost/utility/base_from_member.hpp
==============================================================================
--- trunk/boost/utility/base_from_member.hpp (original)
+++ trunk/boost/utility/base_from_member.hpp 2012-02-16 20:55:33 EST (Thu, 16 Feb 2012)
@@ -15,6 +15,10 @@
 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
 #include <boost/preprocessor/repetition/enum_params.hpp>
 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
+#include <boost/type_traits/is_same.hpp>
+#include <boost/type_traits/remove_cv.hpp>
+#include <boost/type_traits/remove_reference.hpp>
+#include <boost/utility/enable_if.hpp>
 
 
 // Base-from-member arity configuration macro ------------------------------//
@@ -54,6 +58,59 @@
 namespace boost
 {
 
+namespace detail
+{
+
+// Type-unmarking class template -------------------------------------------//
+
+// Type-trait to get the raw type, i.e. the type without top-level reference nor
+// cv-qualification, from a type expression. Mainly for function arguments, any
+// reference part is stripped first.
+
+// Contributed by Daryle Walker
+
+template < typename T >
+struct remove_cv_ref
+{
+ typedef typename ::boost::remove_cv<typename
+ ::boost::remove_reference<T>::type>::type type;
+
+}; // boost::detail::remove_cv_ref
+
+// Unmarked-type comparison class template ---------------------------------//
+
+// Type-trait to check if two type expressions have the same raw type.
+
+// Contributed by Daryle Walker, based on a work-around by Luc Danton
+
+template < typename T, typename U >
+struct is_related
+ : public ::boost::is_same<
+ typename ::boost::detail::remove_cv_ref<T>::type,
+ typename ::boost::detail::remove_cv_ref<U>::type >
+{};
+
+// Enable-if-on-unidentical-unmarked-type class template -------------------//
+
+// Enable-if on the first two type expressions NOT having the same raw type.
+
+// Contributed by Daryle Walker, based on a work-around by Luc Danton
+
+#ifndef BOOST_NO_VARIADIC_TEMPLATES
+template<typename ...T>
+struct enable_if_unrelated
+ : public ::boost::enable_if_c<true>
+{};
+
+template<typename T, typename U, typename ...U2>
+struct enable_if_unrelated<T, U, U2...>
+ : public ::boost::disable_if< ::boost::detail::is_related<T, U> >
+{};
+#endif
+
+} // namespace boost::detail
+
+
 // Base-from-member class template -----------------------------------------//
 
 // Helper to initialize a base object so a derived class can use this
@@ -69,8 +126,11 @@
 protected:
     MemberType member;
 
-#if defined(BOOST_HAS_RVALUE_REFS) && defined(BOOST_HAS_VARIADIC_TMPL)
- template <typename ...T>
+#if !defined(BOOST_NO_RVALUE_REFERENCES) && \
+ !defined(BOOST_NO_VARIADIC_TEMPLATES) && \
+ !defined(BOOST_NO_FUNCTION_TEMPLATE_DEFAULT_ARGS)
+ template <typename ...T, typename EnableIf = typename
+ ::boost::detail::enable_if_unrelated<base_from_member, T...>::type>
     explicit BOOST_CONSTEXPR base_from_member( T&& ...x )
         BOOST_NOEXCEPT_IF( BOOST_NOEXCEPT_EXPR(::new ((void*) 0) MemberType(
          static_cast<T&&>(x)... )) ) // no std::is_nothrow_constructible...

Modified: trunk/libs/utility/base_from_member.html
==============================================================================
--- trunk/libs/utility/base_from_member.html (original)
+++ trunk/libs/utility/base_from_member.html 2012-02-16 20:55:33 EST (Thu, 16 Feb 2012)
@@ -174,16 +174,18 @@
 data member called <var>member</var> that the derived class can use
 for later base classes (or itself).</p>
 
-<p>If the variadic template arguments and r-value reference features of C++2011
-are present, there will be a single constructor template. It implements
-&quot;perfect forwarding&quot; to the best constructor call of
-<code>member</code> (if any). The constructor template is marked both
-<code>constexpr</code> and <code>explicit</code>. The former will be ignored
-if the corresponding inner constructor call (of <code>member</code>) does not
-have the marker. The latter binds the other way; always taking effect, even
-when the inner constructor call does not have the marker. The constructor
-template propagates the <code>noexcept</code> status of the inner constructor
-call.</p>
+<p>If the appropriate features of C++2011 are present, there will be a single
+constructor template. It implements &quot;perfect forwarding&quot; to the best
+constructor call of <code>member</code> (if any). The constructor template is
+marked both <code>constexpr</code> and <code>explicit</code>. The former will
+be ignored if the corresponding inner constructor call (of <code>member</code>)
+does not have the marker. The latter binds the other way; always taking
+effect, even when the inner constructor call does not have the marker. The
+constructor template propagates the <code>noexcept</code> status of the inner
+constructor call. (The constructor template has a trailing parameter with a
+default value that disables the template when its signature is too close to the
+signatures of the automatically-defined non-template copy- and/or
+move-constructors of <code>base_from_member</code>.)</p>
 
 <p>On earlier-standard compilers, there is a default constructor and several
 constructor member templates. These constructor templates can take as many
@@ -385,7 +387,7 @@
 
 <hr>
 
-<p>Revised: 11 February 2012</p>
+<p>Revised: 16 February 2012</p>
 
 <p>Copyright 2001, 2003, 2004, 2012 Daryle Walker. Use, modification, and distribution
 are subject to the Boost Software License, Version 1.0. (See accompanying


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