Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62272 - in branches/release: boost/parameter boost/parameter/aux_ libs/parameter/doc
From: andrey.semashev_at_[hidden]
Date: 2010-05-27 13:58:59


Author: andysem
Date: 2010-05-27 13:58:58 EDT (Thu, 27 May 2010)
New Revision: 62272
URL: http://svn.boost.org/trac/boost/changeset/62272

Log:
Merged changes from trunk.
Added:
   branches/release/boost/parameter/aux_/is_maybe.hpp (contents, props changed)
Text files modified:
   branches/release/boost/parameter/aux_/arg_list.hpp | 38 ++++------
   branches/release/boost/parameter/aux_/maybe.hpp | 60 +++++++++++-----
   branches/release/boost/parameter/preprocessor.hpp | 4
   branches/release/libs/parameter/doc/index.rst | 138 +++++++++++++++++++++------------------
   branches/release/libs/parameter/doc/python.rst | 10 +-
   branches/release/libs/parameter/doc/reference.rst | 8 +-
   6 files changed, 144 insertions(+), 114 deletions(-)

Modified: branches/release/boost/parameter/aux_/arg_list.hpp
==============================================================================
--- branches/release/boost/parameter/aux_/arg_list.hpp (original)
+++ branches/release/boost/parameter/aux_/arg_list.hpp 2010-05-27 13:58:58 EDT (Thu, 27 May 2010)
@@ -11,7 +11,7 @@
 #include <boost/parameter/aux_/default.hpp>
 #include <boost/parameter/aux_/parameter_requirements.hpp>
 #include <boost/parameter/aux_/yesno.hpp>
-#include <boost/parameter/aux_/maybe.hpp>
+#include <boost/parameter/aux_/is_maybe.hpp>
 #include <boost/parameter/config.hpp>
 
 #include <boost/mpl/apply.hpp>
@@ -22,12 +22,11 @@
 
 #include <boost/type_traits/add_reference.hpp>
 #include <boost/type_traits/is_same.hpp>
-#include <boost/type_traits/is_base_and_derived.hpp>
 #include <boost/preprocessor/repetition/enum_params.hpp>
 #include <boost/preprocessor/repetition/enum_binary_params.hpp>
 #include <boost/preprocessor/facilities/intercept.hpp>
 
-namespace boost { namespace parameter {
+namespace boost { namespace parameter {
 
 // Forward declaration for aux::arg_list, below.
 template<class T> struct keyword;
@@ -47,7 +46,7 @@
 // declarations to build member function overload sets that can
 // match against keywords.
 //
-
+
 // MPL sequence support
 struct arg_list_tag;
 
@@ -84,14 +83,14 @@
     template <class KW>
     static no_tag has_key(KW*);
 #endif
-
+
 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
     || (BOOST_WORKAROUND(__GNUC__, < 3)) \
     || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
-
+
     // The overload set technique doesn't work with these older
     // compilers, so they need some explicit handholding.
-
+
     // A metafunction class that, given a keyword, returns the type
     // of the base sublist whose get() function can produce the
     // value for that key
@@ -161,11 +160,6 @@
 struct tagged_argument;
 
 template <class T>
-struct is_maybe
- : is_base_and_derived<maybe_base, T>
-{};
-
-template <class T>
 struct get_reference
 {
     typedef typename T::reference type;
@@ -212,9 +206,9 @@
     // Create a new list by prepending arg to a copy of tail. Used
     // when incrementally building this structure with the comma
     // operator.
- arg_list(TaggedArg arg, Next const& tail)
+ arg_list(TaggedArg head, Next const& tail)
       : Next(tail)
- , arg(arg)
+ , arg(head)
     {}
 
     // A metafunction class that, given a keyword and a default
@@ -242,8 +236,8 @@
     // same keyword is used again
     static yes_tag has_key(key_type*);
     using Next::has_key;
-
-# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) next::has_key((key*)0)
+
+# define BOOST_PARAMETER_CALL_HAS_KEY(next, key) next::has_key((key*)0)
 # endif
 
     BOOST_MPL_ASSERT_MSG(
@@ -258,7 +252,7 @@
     // specific arguments by name
     //
 
- // Helpers that handle the case when TaggedArg is
+ // Helpers that handle the case when TaggedArg is
     // empty<T>.
     template <class D>
     reference get_default(D const&, mpl::false_) const
@@ -338,7 +332,7 @@
     template <class Default>
     reference get(default_<key_type,Default> const& d) const
     {
- return get_default(d, holds_maybe());
+ return get_default(d, holds_maybe());
     }
 
     template <class Default>
@@ -346,7 +340,7 @@
     {
         return arg.value;
     }
-
+
 #else
 
     reference operator[](keyword<key_type> const&) const
@@ -401,7 +395,7 @@
     // Comma operator to compose argument list without using parameters<>.
     // Useful for argument lists with undetermined length.
     template <class KW, class T2>
- arg_list<tagged_argument<KW, T2>, self>
+ arg_list<tagged_argument<KW, T2>, self>
     operator,(tagged_argument<KW,T2> x) const
     {
         return arg_list<tagged_argument<KW,T2>, self>(x, *this);
@@ -415,7 +409,7 @@
 
 #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // ETI workaround
 template <> struct arg_list<int,int> {};
-#endif
+#endif
 
 // MPL sequence support
 template <class ArgumentPack>
@@ -425,7 +419,7 @@
 
     // The incremented iterator
     typedef arg_list_iterator<typename ArgumentPack::tail_type> next;
-
+
     // dereferencing yields the key type
     typedef typename ArgumentPack::key_type type;
 };

Added: branches/release/boost/parameter/aux_/is_maybe.hpp
==============================================================================
--- (empty file)
+++ branches/release/boost/parameter/aux_/is_maybe.hpp 2010-05-27 13:58:58 EDT (Thu, 27 May 2010)
@@ -0,0 +1,26 @@
+// Copyright Daniel Wallin, David Abrahams 2010. Use, modification and
+// distribution is subject to 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)
+
+#ifndef BOOST_PARAMETER_IS_MAYBE_050329_HPP
+#define BOOST_PARAMETER_IS_MAYBE_050329_HPP
+
+#include <boost/type_traits/is_base_and_derived.hpp>
+
+namespace boost {
+namespace parameter {
+namespace aux {
+
+struct maybe_base {};
+
+template <class T>
+struct is_maybe
+ : is_base_and_derived<maybe_base, T>
+{};
+
+} // namespace aux
+} // namespace parameter
+} // namespace boost
+
+#endif // BOOST_PARAMETER_IS_MAYBE_050329_HPP

Modified: branches/release/boost/parameter/aux_/maybe.hpp
==============================================================================
--- branches/release/boost/parameter/aux_/maybe.hpp (original)
+++ branches/release/boost/parameter/aux_/maybe.hpp 2010-05-27 13:58:58 EDT (Thu, 27 May 2010)
@@ -2,21 +2,41 @@
 // subject to 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)
 
-#ifndef BOOST_PARAMETER_MAYBE_060211_HPP
-# define BOOST_PARAMETER_MAYBE_060211_HPP
+//
+// 2009.10.21 TDS remove depenency on boost::python::detail::referent_storage
+//
+#ifndef BOOST_PARAMETER_MAYBE_091021_HPP
+# define BOOST_PARAMETER_MAYBE_091021_HPP
 
 # include <boost/mpl/if.hpp>
 # include <boost/mpl/identity.hpp>
 # include <boost/type_traits/is_reference.hpp>
 # include <boost/type_traits/add_reference.hpp>
 # include <boost/optional.hpp>
-# include <boost/python/detail/referent_storage.hpp>
+# include <boost/aligned_storage.hpp>
 # include <boost/type_traits/remove_cv.hpp>
 # include <boost/type_traits/add_const.hpp>
+# include <boost/parameter/aux_/is_maybe.hpp>
 
 namespace boost { namespace parameter { namespace aux {
 
-struct maybe_base {};
+template <class T> struct referent_size;
+
+template <class T>
+struct referent_size<T&>
+{
+ BOOST_STATIC_CONSTANT(std::size_t, value = sizeof(T));
+};
+
+// A metafunction returning a POD type which can store U, where T ==
+// U&. If T is not a reference type, returns a POD which can store T.
+template <class T>
+struct referent_storage
+{
+ typedef typename boost::aligned_storage<
+ referent_size<T>::value
+ >::type type;
+};
 
 template <class T>
 struct maybe : maybe_base
@@ -24,17 +44,17 @@
     typedef typename add_reference<
 # if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
         T const
-# else
+# else
         typename add_const<T>::type
-# endif
+# endif
>::type reference;
-
+
     typedef typename remove_cv<
         BOOST_DEDUCED_TYPENAME remove_reference<reference>::type
>::type non_cv_value;
-
- explicit maybe(T value)
- : value(value)
+
+ explicit maybe(T value_)
+ : value(value_)
       , constructed(false)
     {}
 
@@ -48,28 +68,28 @@
             this->destroy();
     }
 
- reference construct(reference value) const
+ reference construct(reference value_) const
     {
- return value;
+ return value_;
     }
 
     template <class U>
- reference construct2(U const& value) const
+ reference construct2(U const& value_) const
     {
- new (m_storage.bytes) non_cv_value(value);
+ new (m_storage.address()) non_cv_value(value_);
         constructed = true;
- return *(non_cv_value*)m_storage.bytes;
+ return *(non_cv_value*)m_storage.address();
     }
 
     template <class U>
- reference construct(U const& value) const
+ reference construct(U const& value_) const
     {
- return this->construct2(value);
+ return this->construct2(value_);
     }
 
     void destroy()
     {
- ((non_cv_value*)m_storage.bytes)->~non_cv_value();
+ ((non_cv_value*)m_storage.address())->~non_cv_value();
     }
 
     typedef reference(maybe<T>::*safe_bool)() const;
@@ -87,7 +107,9 @@
 private:
     boost::optional<T> value;
     mutable bool constructed;
- mutable typename boost::python::detail::referent_storage<
+
+
+ mutable typename referent_storage<
         reference
>::type m_storage;
 };

Modified: branches/release/boost/parameter/preprocessor.hpp
==============================================================================
--- branches/release/boost/parameter/preprocessor.hpp (original)
+++ branches/release/boost/parameter/preprocessor.hpp 2010-05-27 13:58:58 EDT (Thu, 27 May 2010)
@@ -25,10 +25,12 @@
 # include <boost/preprocessor/seq/for_each_product.hpp>
 # include <boost/preprocessor/seq/for_each_i.hpp>
 # include <boost/preprocessor/tuple/elem.hpp>
+# include <boost/preprocessor/tuple/eat.hpp>
 # include <boost/preprocessor/seq/fold_left.hpp>
 # include <boost/preprocessor/seq/push_back.hpp>
 # include <boost/preprocessor/seq/size.hpp>
 # include <boost/preprocessor/seq/enum.hpp>
+# include <boost/preprocessor/seq/push_back.hpp>
 
 # include <boost/preprocessor/detail/is_nullary.hpp>
 
@@ -361,7 +363,7 @@
 # define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n) \
     , typename boost::parameter::aux::match< \
           parameters, BOOST_PP_ENUM_PARAMS(n, ParameterArgumentType) \
- >::type boost_parameter_enabler_argument = parameters()
+ >::type = parameters()
 # else
 # define BOOST_PARAMETER_FUNCTION_FWD_MATCH_Z(z, name, parameters, n)
 # endif

Modified: branches/release/libs/parameter/doc/index.rst
==============================================================================
--- branches/release/libs/parameter/doc/index.rst (original)
+++ branches/release/libs/parameter/doc/index.rst 2010-05-27 13:58:58 EDT (Thu, 27 May 2010)
@@ -71,16 +71,16 @@
 -------------------------------------
 
 :Authors: David Abrahams, Daniel Wallin
-:Contact: dave_at_[hidden], dalwan01_at_[hidden]
-:Organization: `Boost Consulting`_
-:Date: $Date: 2005/07/18 20:34:31 $
+:Contact: dave_at_[hidden], daniel_at_[hidden]
+:organization: `BoostPro Computing`_
+:date: $Date: 2005/07/17 19:53:01 $
 
-:Copyright: Copyright David Abrahams, Daniel Wallin 2005.
- Distributed under the Boost Software License,
+:copyright: Copyright David Abrahams, Daniel Wallin
+ 2005-2009. 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)
 
-.. _`Boost Consulting`: http://www.boost-consulting.com
+.. _`BoostPro Computing`: http://www.boostpro.com
 
 .. _concepts: http://www.boost.org/more/generic_programming.html#concept
 
@@ -1112,7 +1112,7 @@
   struct callable2
   {
       BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
- (void), operator(), tag, (required (arg1,(int))(arg2,(int))))
+ (void), call, tag, (required (arg1,(int))(arg2,(int))))
       {
           std::cout << arg1 << ", " << arg2 << std::endl;
       }
@@ -1120,7 +1120,9 @@
 
 .. @example.prepend('''
    #include <boost/parameter.hpp>
- #include <iostream>''')
+ #include <iostream>
+ using namespace boost::parameter;
+ ''')
 
 .. @test('compile')
 
@@ -1131,7 +1133,7 @@
   struct callable2
   {
       BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
- (void), operator(), tag, (required (arg1,(int))(arg2,(int))))
+ (void), call, tag, (required (arg1,(int))(arg2,(int))))
       {
           call_impl(arg1,arg2);
       }
@@ -1143,10 +1145,40 @@
    #include <boost/parameter.hpp>
 
    BOOST_PARAMETER_NAME(arg1)
- BOOST_PARAMETER_NAME(arg2)''')
+ BOOST_PARAMETER_NAME(arg2)
+ using namespace boost::parameter;
+ ''')
 
 .. @test('compile')
 
+Static Member Functions
+=======================
+
+To expose a static member function, simply insert the keyword
+“``static``” before the function name:
+
+.. parsed-literal::
+
+ BOOST_PARAMETER_NAME(arg1)
+
+ struct somebody
+ {
+ BOOST_PARAMETER_MEMBER_FUNCTION(
+ (void), **static** f, tag, (optional (arg1,(int),0)))
+ {
+ std::cout << arg1 << std::endl;
+ }
+ };
+
+.. @example.prepend('''
+ #include <boost/parameter.hpp>
+ #include <iostream>
+ using namespace boost::parameter;
+ ''')
+
+.. @test('compile')
+
+
 ------------------------------
 Parameter-Enabled Constructors
 ------------------------------
@@ -1339,10 +1371,10 @@
   using boost::mpl::_;
 
   typedef parameter::parameters<
- required<tag::class_type, is_class<_> >
- , optional<tag::base_list, mpl::is_sequence<_> >
- , optional<tag::held_type>
- , optional<tag::copyable>
+ required<tag::class_type, boost::is_class<_> >
+ , parameter::optional<tag::base_list, mpl::is_sequence<_> >
+ , parameter::optional<tag::held_type>
+ , parameter::optional<tag::copyable>
> class_signature;
 
   }}
@@ -1351,6 +1383,7 @@
    #include <boost/parameter.hpp>
    #include <boost/mpl/is_sequence.hpp>
    #include <boost/noncopyable.hpp>
+ #include <boost/type_traits/is_class.hpp>
    #include <memory>
 
    using namespace boost::parameter;
@@ -1377,12 +1410,13 @@
 Argument Packs and Parameter Extraction
 ---------------------------------------
 
-Next, within the body of ``class_`` , we use the |ParameterSpec|\
-'s nested ``::bind< … >`` template to bundle the actual arguments
-into an |ArgumentPack|_ type, and then use the library's ``binding<
-… >`` metafunction to extract “logical parameters”. Note that
-defaults are specified by supplying an optional third argument to
-``binding< … >``::
+Next, within the body of ``class_`` , we use the |ParameterSpec|\ 's
+nested ``::bind< … >`` template to bundle the actual arguments into an
+|ArgumentPack|_ type, and then use the library's ``value_type< … >``
+metafunction to extract “logical parameters”. ``value_type< … >`` is
+a lot like ``binding< … >``, but no reference is added to the actual
+argument type. Note that defaults are specified by passing it an
+optional third argument::
 
   namespace boost { namespace python {
 
@@ -1400,16 +1434,16 @@
       args;
 
       // Extract first logical parameter.
- typedef typename parameter::binding<
+ typedef typename parameter::value_type<
         args, tag::class_type>::type class_type;
       
- typedef typename parameter::binding<
+ typedef typename parameter::value_type<
         args, tag::base_list, bases<> >::type base_list;
       
- typedef typename parameter::binding<
+ typedef typename parameter::value_type<
         args, tag::held_type, class_type>::type held_type;
       
- typedef typename parameter::binding<
+ typedef typename parameter::value_type<
         args, tag::copyable, void>::type copyable;
   };
 
@@ -1511,12 +1545,12 @@
   typedef parameter::parameters<
       required<tag::class_type, is_class<_> >
 
- , optional<
+ , parameter::optional<
           deduced<tag::base_list>
         , is_base_and_derived<detail::bases_base,_>
>
 
- , optional<
+ , parameter::optional<
           deduced<tag::held_type>
         , mpl::not_<
               mpl::or_<
@@ -1526,11 +1560,12 @@
>
>
 
- , optional<deduced<tag::copyable>, is_same<noncopyable,_> >
+ , parameter::optional<deduced<tag::copyable>, is_same<noncopyable,_> >
 
> class_signature;
 
 .. @example.prepend('''
+ #include <boost/type_traits/is_class.hpp>
    namespace boost { namespace python {''')
 
 .. @example.append('''
@@ -1548,16 +1583,16 @@
        args;
  
        // Extract first logical parameter.
- typedef typename parameter::binding<
+ typedef typename parameter::value_type<
          args, tag::class_type>::type class_type;
       
- typedef typename parameter::binding<
+ typedef typename parameter::value_type<
          args, tag::base_list, bases<> >::type base_list;
       
- typedef typename parameter::binding<
+ typedef typename parameter::value_type<
          args, tag::held_type, class_type>::type held_type;
       
- typedef typename parameter::binding<
+ typedef typename parameter::value_type<
          args, tag::copyable, void>::type copyable;
    };
 
@@ -1778,15 +1813,13 @@
 Occasionally one needs to deduce argument types without an extra
 layer of function call. For example, suppose we wanted to return
 twice the value of the ``index`` parameter? In that
-case we can use the ``binding< … >`` metafunction introduced
+case we can use the ``value_type< … >`` metafunction introduced
 `earlier`__::
 
    BOOST_PARAMETER_NAME(index)
 
    template <class ArgumentPack>
- typename remove_reference<
- typename parameter::binding<ArgumentPack, tag::index, int>::type
- >::type
+ typename parameter::value_type<ArgumentPack, tag::index, int>::type
    twice_index(ArgumentPack const& args)
    {
        return 2 * args[_index|42];
@@ -1800,39 +1833,20 @@
    #include <cassert>
 
    namespace parameter = boost::parameter;
- using boost::remove_reference;''')
-
-Note that the ``remove_reference< … >`` dance is necessary because
-``binding< … >`` will return a reference type when the argument
-is bound in the argument pack. If we don't strip the reference we
-end up returning a reference to the temporary created in the ``2 * …``
-expression. A convenient shortcut would be to use the ``value_type< … >``
-metafunction:
-
-.. parsed-literal::
-
- template <class ArgumentPack>
- typename **parameter::value_type<ArgumentPack, tag::index, int>**::type
- twice_index(ArgumentPack const& args)
- {
- return 2 * args[_index|42];
- }
-
-.. @example.wrap('namespace with_value_type {', '''
- int six = twice_index(_index = 3);
- }''')
-
-.. TODO: binding<> returns a reference. We should use value_type<> here.
+ ''')
 
 .. @example.append('''
    int main()
    {
        assert(six == 6);
- assert(with_value_type::six == 6);
    }''')
 
 .. @test('run', howmany='all')
 
+Note that if we had used ``binding< … >`` rather than ``value_type< …
+>``, we would end up returning a reference to the temporary created in
+the ``2 * …`` expression.
+
 __ binding_intro_
 
 Lazy Default Computation
@@ -1888,12 +1902,10 @@
 
 .. parsed-literal::
 
- using boost::bind;
- using boost::ref;
-
    typename parameter::binding<
        ArgumentPack, tag::s3, std::string
- >::type s3 = args[_s3 **|| bind(std::plus<std::string>(), ref(s1), ref(s2))** ];
+ >::type s3 = args[_s3
+ **|| boost::bind(std::plus<std::string>(), boost::ref(s1), boost::ref(s2))** ];
 
 .. @example.prepend('''
    #include <boost/bind.hpp>

Modified: branches/release/libs/parameter/doc/python.rst
==============================================================================
--- branches/release/libs/parameter/doc/python.rst (original)
+++ branches/release/libs/parameter/doc/python.rst 2010-05-27 13:58:58 EDT (Thu, 27 May 2010)
@@ -2,13 +2,13 @@
  The Boost Parameter Library Python Binding Documentation
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
-:Authors: Daniel Wallin
-:Contact: dalwan01_at_[hidden]
-:organization: `Boost Consulting`_
+:Authors: David Abrahams, Daniel Wallin
+:Contact: dave_at_[hidden], daniel_at_[hidden]
+:organization: `BoostPro Computing`_
 :date: $Date$
 
 :copyright: Copyright David Abrahams, Daniel Wallin
- 2005. Distributed under the Boost Software License,
+ 2005-2009. 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)
 
@@ -22,7 +22,7 @@
 
 __ ../../../../index.htm
 
-.. _`Boost Consulting`: http://www.boost-consulting.com
+.. _`BoostPro Computing`: http://www.boostpro.com
 
 
 .. role:: class

Modified: branches/release/libs/parameter/doc/reference.rst
==============================================================================
--- branches/release/libs/parameter/doc/reference.rst (original)
+++ branches/release/libs/parameter/doc/reference.rst 2010-05-27 13:58:58 EDT (Thu, 27 May 2010)
@@ -3,12 +3,12 @@
 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 
 :Authors: David Abrahams, Daniel Wallin
-:Contact: dave_at_[hidden], dalwan01_at_[hidden]
-:organization: `Boost Consulting`_
+:Contact: dave_at_[hidden], daniel_at_[hidden]
+:organization: `BoostPro Computing`_
 :date: $Date: 2005/07/17 19:53:01 $
 
 :copyright: Copyright David Abrahams, Daniel Wallin
- 2005. Distributed under the Boost Software License,
+ 2005-2009. 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)
 
@@ -19,7 +19,7 @@
 
 __ ../../../../index.htm
 
-.. _`Boost Consulting`: http://www.boost-consulting.com
+.. _`BoostPro Computing`: http://www.boostpro.com
 
 
 //////////////////////////////////////////////////////////////////////////////


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