Boost logo

Boost-Commit :

From: stipe_at_[hidden]
Date: 2008-08-14 01:16:39


Author: srajko
Date: 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
New Revision: 48136
URL: http://svn.boost.org/trac/boost/changeset/48136

Log:
add field_map tests
Added:
   sandbox/guigl/
   sandbox/guigl/Jamroot (contents, props changed)
   sandbox/guigl/LICENSE_1_0.txt (contents, props changed)
   sandbox/guigl/boost/
   sandbox/guigl/boost/field_map/
   sandbox/guigl/boost/field_map/field_map.hpp (contents, props changed)
   sandbox/guigl/libs/
   sandbox/guigl/libs/guigl/
   sandbox/guigl/libs/guigl/test/
   sandbox/guigl/libs/guigl/test/Jamfile (contents, props changed)
   sandbox/guigl/libs/guigl/test/test_field_map.cpp (contents, props changed)
   sandbox/guigl/libs/guigl/test/test_field_map_compilation.cpp (contents, props changed)
   sandbox/guigl/libs/guigl/test/test_field_map_compilation.hpp (contents, props changed)
   sandbox/guigl/libs/guigl/test/test_parameter_compilation.cpp (contents, props changed)
   sandbox/guigl/libs/guigl/test/test_parameter_compilation.hpp (contents, props changed)
   sandbox/guigl/libs/guigl/test/test_parameter_dispatch_compilation.cpp (contents, props changed)
   sandbox/guigl/libs/guigl/test/test_parameter_dispatch_compilation.hpp (contents, props changed)

Added: sandbox/guigl/Jamroot
==============================================================================
--- (empty file)
+++ sandbox/guigl/Jamroot 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,36 @@
+#==================================---------------------------------------------
+# Copyright 2008 Stjepan Rajko
+#
+# 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)
+#----------------------------------------------===============================*/
+
+import os ;
+
+# Set the BOOST_ROOT environment variable on your command-line or in the
+# environment to point at the root of your regular Boost installation.
+
+# get the BOOST_ROOT environment variable
+path-constant BOOST_ROOT : [ os.environ BOOST_ROOT ] ;
+
+# record the root of the datalow directory structure
+path-constant TOP : . ;
+
+# we are using Boost
+use-project boost
+ : $(BOOST_ROOT)
+ ;
+
+use-project guigl : libs/guigl/build ;
+
+# the Dataflow project and anything using it needs Dataflow and Boost headers
+project guigl
+ : build-dir bin.v2
+ : usage-requirements
+ <include>.
+ <include>$(BOOST_ROOT)
+ : requirements
+ <include>.
+ <include>$(BOOST_ROOT)
+ ;
\ No newline at end of file

Added: sandbox/guigl/LICENSE_1_0.txt
==============================================================================
--- (empty file)
+++ sandbox/guigl/LICENSE_1_0.txt 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,23 @@
+Boost Software License - Version 1.0 - August 17th, 2003
+
+Permission is hereby granted, free of charge, to any person or organization
+obtaining a copy of the software and accompanying documentation covered by
+this license (the "Software") to use, reproduce, display, distribute,
+execute, and transmit the Software, and to prepare derivative works of the
+Software, and to permit third-parties to whom the Software is furnished to
+do so, all subject to the following:
+
+The copyright notices in the Software and this entire statement, including
+the above license grant, this restriction and the following disclaimer,
+must be included in all copies of the Software, in whole or in part, and
+all derivative works of the Software, unless such copies or derivative
+works are solely in the form of machine-executable object code generated by
+a source language processor.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
+SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
+FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+DEALINGS IN THE SOFTWARE.

Added: sandbox/guigl/boost/field_map/field_map.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/boost/field_map/field_map.hpp 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,191 @@
+/*=================================---------------------------------------------
+ Copyright 2008 Stjepan Rajko
+
+ 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)
+-----------------------------------------------===============================*/
+
+#ifndef BOOST__FIELD_MAP__FIELD_MAP_HPP
+#define BOOST__FIELD_MAP__FIELD_MAP_HPP
+
+
+#include <boost/fusion/algorithm/iteration/for_each.hpp>
+#include <boost/fusion/algorithm/transformation/join.hpp>
+#include <boost/fusion/container/map.hpp>
+#include <boost/fusion/sequence/intrinsic/at_key.hpp>
+#include <boost/fusion/sequence/intrinsic/has_key.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/repetition/enum.hpp>
+#include <boost/utility/enable_if.hpp>
+
+#include <string>
+
+
+namespace boost { namespace field_map {
+
+namespace detail {
+
+ template<typename Field>
+ struct pair
+ {
+ typedef fusion::pair<Field, typename Field::type> type;
+ };
+
+ template<>
+ struct pair<fusion::void_>
+ {
+ typedef fusion::void_ type;
+ };
+
+ template<typename SourceMap>
+ struct copy
+ {
+ copy(const SourceMap &source)
+ : source(source)
+ {}
+
+ template<typename DestPair>
+ typename disable_if<
+ fusion::result_of::has_key<SourceMap, typename DestPair::first_type>
+ >::type operator()(DestPair &dest) const
+ {
+ typedef typename DestPair::first_type field;
+ dest = fusion::make_pair<field>(field::default_value());
+ }
+
+ template<typename DestPair>
+ typename enable_if<
+ fusion::result_of::has_key<SourceMap, typename DestPair::first_type>
+ >::type operator()(DestPair &dest) const
+ {
+ typedef typename DestPair::first_type key;
+ dest = fusion::make_pair<key>(fusion::at_key<key>(source));
+ }
+
+ const SourceMap &source;
+ };
+
+}
+
+template<typename Map>
+class field_map
+{
+public:
+ typedef Map map_type;
+
+ // all default values - todo
+ field_map()
+ {
+ }
+
+ // initialize from a fusion map
+ field_map(const Map &map)
+ : m_map(map)
+ {}
+
+ // get values from a different FieldMap
+ template<typename OtherMap>
+ field_map(const field_map<OtherMap> &other_field_map)
+ {
+ fusion::for_each(m_map, detail::copy<OtherMap>(other_field_map.map()));
+ }
+
+ template<typename Field>
+ const typename Field::type &at() const
+ { return fusion::at_key<Field>(m_map); }
+
+ template<typename FieldObject>
+ const typename FieldObject::field_type::type &operator[](const FieldObject &) const
+ { return fusion::at_key<typename FieldObject::field_type>(m_map); }
+
+ const Map &map() const
+ { return m_map; }
+private:
+ Map m_map;
+};
+
+namespace detail {
+
+ template<typename LeftFieldMap, typename RightFieldMap>
+ struct join_map
+ {
+ typedef field_map<
+ typename
+ fusion::result_of::as_map<
+ typename fusion::result_of::join<
+ typename LeftFieldMap::map_type,
+ typename RightFieldMap::map_type
+ >::type
+ >::type
+ > type;
+ };
+}
+
+template<typename LeftFieldMap, typename RightFieldMap>
+typename detail::join_map<LeftFieldMap, RightFieldMap>::type
+ operator, (const LeftFieldMap &lhs, const RightFieldMap &rhs)
+{
+ return typename detail::join_map<LeftFieldMap, RightFieldMap>::type(fusion::join(lhs.map(), rhs.map()));
+}
+
+template<typename LeftFieldMap, typename RightFieldMap>
+typename detail::join_map<LeftFieldMap, RightFieldMap>::type
+ operator& (const LeftFieldMap &lhs, const RightFieldMap &rhs)
+{
+ return (lhs,rhs);
+}
+
+#ifndef BOOST_FIELDMAP_MAX_ARGS
+#define BOOST_FIELDMAP_MAX_ARGS 9
+#endif
+
+#define BOOST_FIELDMAP_PACK_TYPENAME(z,n,text) typename T##n=fusion::void_
+#define BOOST_FIELDMAP_PACK_FIELD_TYPE(z,n,text) typename detail::pair<T##n>::type
+
+template<BOOST_PP_ENUM(BOOST_FIELDMAP_MAX_ARGS, BOOST_FIELDMAP_PACK_TYPENAME, _)>
+struct map
+{
+ typedef field_map<fusion::map<BOOST_PP_ENUM(BOOST_FIELDMAP_MAX_ARGS, BOOST_FIELDMAP_PACK_FIELD_TYPE, _)> > type;
+};
+
+typedef map<>::type empty_map_type;
+
+
+#define BOOST_FIELD_MAP_FIELD_FUNCTION(field,function) \
+map<field>::type function(const field::type &value) \
+{ \
+ return map<field>::type(value); \
+}
+
+#define BOOST_FIELD_MAP_FIELD_ASSIGNABLE(field,assigner) \
+namespace { \
+struct BOOST_PP_CAT(assigner,_type) \
+{ \
+ map<field>::type operator=(const field::type &value) const \
+ { \
+ return map<field>::type(value); \
+ } \
+}; } \
+static const BOOST_PP_CAT(assigner,_type) assigner = BOOST_PP_CAT(assigner,_type)();
+
+#define BOOST_FIELD_MAP_PARAMETER(field_name,param_type) \
+namespace field { \
+ struct field_name { \
+ typedef param_type type; \
+ }; \
+} \
+namespace { \
+struct BOOST_PP_CAT(field_name,_type) \
+{ \
+ typedef field::field_name field_type; \
+ map<field::field_name>::type operator=(const field::field_name::type &value) const \
+ { \
+ return map<field::field_name>::type(value); \
+ } \
+}; } \
+static const BOOST_PP_CAT(field_name,_type) field_name = BOOST_PP_CAT(field_name,_type)();
+
+}}
+
+#endif // BOOST__FIELD_MAP__FIELD_MAP_HPP
\ No newline at end of file

Added: sandbox/guigl/libs/guigl/test/Jamfile
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/test/Jamfile 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,28 @@
+#==================================---------------------------------------------
+# Copyright 2008 Stjepan Rajko
+#
+# 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)
+#----------------------------------------------===============================*/
+
+
+import testing ;
+
+project guigl/test
+ : requirements
+ <define>BOOST_ALL_NO_LIB=1
+ <library>/boost/test//boost_unit_test_framework/<link>static
+ ;
+
+run test_field_map.cpp ;
+run test_field_map_compilation.cpp ;
+run test_parameter_compilation.cpp ;
+run test_parameter_dispatch_compilation.cpp ;
+
+#obj test_field_map_compilation : test_field_map_compilation.cpp ;
+#time time-test_field_map_compilation : test_field_map_compilation ;
+#obj test_parameter_compilation : test_parameter_compilation.cpp ;
+#time time-test_parameter_compilation : test_parameter_compilation ;
+#obj test_parameter_dispatch_compilation : test_parameter_dispatch_compilation.cpp ;
+#time time-test_parameter_dispatch_compilation : test_parameter_dispatch_compilation ;
\ No newline at end of file

Added: sandbox/guigl/libs/guigl/test/test_field_map.cpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/test/test_field_map.cpp 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,150 @@
+/*=================================---------------------------------------------
+ Copyright 2008 Stjepan Rajko
+
+ 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)
+-----------------------------------------------===============================*/
+
+
+#include <boost/field_map/field_map.hpp>
+
+#include <boost/typeof/typeof.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+using namespace boost;
+
+using namespace boost::field_map;
+
+namespace field {
+
+ struct label
+ {
+ typedef std::string type;
+ };
+
+ struct size
+ {
+ typedef int type;
+
+ static type default_value()
+ {
+ return 3;
+ }
+ };
+
+ struct volume
+ {
+ typedef double type;
+
+ static type default_value()
+ {
+ return 3.0;
+ }
+ };
+
+}
+
+
+BOOST_FIELD_MAP_FIELD_FUNCTION(field::label, label)
+BOOST_FIELD_MAP_FIELD_FUNCTION(field::size, size)
+
+BOOST_FIELD_MAP_FIELD_ASSIGNABLE(field::label, label_)
+BOOST_FIELD_MAP_FIELD_ASSIGNABLE(field::size, size_)
+BOOST_FIELD_MAP_FIELD_ASSIGNABLE(field::volume, volume_)
+
+
+inline map<>::type empty()
+{
+ return map<>::type();
+}
+
+BOOST_AUTO_TEST_CASE( test_map )
+{
+ BOOST_AUTO(hello, label("hello"));
+ BOOST_CHECK_EQUAL(hello.at<field::label>(), "hello");
+
+ BOOST_AUTO(hello_1, hello&size(1));
+ BOOST_CHECK_EQUAL(hello_1.at<field::label>(), "hello");
+ BOOST_CHECK_EQUAL(hello_1.at<field::size>(), 1);
+
+ BOOST_AUTO(one, size(1));
+ BOOST_CHECK_EQUAL(one.at<field::size>(), 1);
+
+ BOOST_AUTO(one_hello, one&label("hello"));
+ BOOST_CHECK_EQUAL(one_hello.at<field::size>(), 1);
+ BOOST_CHECK_EQUAL(one_hello.at<field::label>(), "hello");
+
+// Following does not compile
+// guigl::parameter::label("hello").label("goodbye");
+// guigl::parameter::size(1).size(1);
+}
+
+
+const std::string &function_taking_label(const map<field::label>::type &args)
+{
+ return args.at<field::label>();
+}
+
+const int &function_taking_size(const map<field::size>::type &args)
+{
+ return args.at<field::size>();
+}
+
+const int &function_taking_both(const map<field::label, field::size>::type &args)
+{
+ return args.at<field::size>();
+}
+
+
+BOOST_AUTO_TEST_CASE( test_call )
+{
+ BOOST_CHECK_EQUAL(function_taking_label(label_="hello"), "hello");
+ BOOST_CHECK_EQUAL(function_taking_size((size(1))), 1);
+
+ // parameters can be passed in any order
+ BOOST_CHECK_EQUAL(function_taking_both((label_="hello", size_=1)), 1);
+ BOOST_CHECK_EQUAL(function_taking_both((size_=1,label_="hello")), 1);
+ // size has a default value
+ BOOST_CHECK_EQUAL(function_taking_both((label("hello"))), field::size::default_value());
+
+ // extraneous parameters will be ignored
+ BOOST_CHECK_EQUAL(function_taking_label((label("hello"),size(1))), "hello");
+
+ // empty parameter map can be used for no parameters (all default values)
+ BOOST_CHECK_EQUAL(function_taking_size(empty()), field::size::default_value());
+}
+
+class named_constructable
+{
+public:
+ // a macro could extend the number of parameters if desired
+ template<typename FM0, typename FM1, typename FM2>
+ named_constructable(const FM0 &a0, const FM1 &a1, const FM2 &a2)
+ {
+ // this could be done lazily...
+ map<field::label, field::size, field::volume>::type args = a0 & a1 & a2;
+
+ label = args.at<field::label>();
+ size = args.at<field::size>();
+ volume = args.at<field::volume>();
+ }
+ std::string label;
+ int size;
+ double volume;
+};
+
+
+BOOST_AUTO_TEST_CASE( test_multi_param_construction )
+{
+ named_constructable constructed(label_ = "hello", size_ = 1, volume_ = 1.0);
+ BOOST_CHECK_EQUAL(constructed.label, "hello");
+ BOOST_CHECK_EQUAL(constructed.size, 1);
+ BOOST_CHECK_EQUAL(constructed.volume, 1.0);
+
+}
+
+
+

Added: sandbox/guigl/libs/guigl/test/test_field_map_compilation.cpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/test/test_field_map_compilation.cpp 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,16 @@
+#include <boost/field_map/field_map.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/cat.hpp>
+#include <boost/preprocessor/facilities/expand.hpp>
+
+
+using namespace boost;
+
+using namespace boost::field_map;
+
+#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 20, <libs/guigl/test/test_field_map_compilation.hpp>))
+ #include BOOST_PP_ITERATE()

Added: sandbox/guigl/libs/guigl/test/test_field_map_compilation.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/test/test_field_map_compilation.hpp 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,41 @@
+using namespace boost;
+
+using namespace boost::field_map;
+
+#define N BOOST_PP_ITERATION()
+
+#define labelN BOOST_PP_CAT(label,N)
+#define sizeN BOOST_PP_CAT(size,N)
+#define volumeN BOOST_PP_CAT(volume,N)
+#define named_constructableN BOOST_PP_CAT(named_constructable,N)
+
+BOOST_FIELD_MAP_PARAMETER(labelN, std::string)
+BOOST_FIELD_MAP_PARAMETER(sizeN, int)
+BOOST_FIELD_MAP_PARAMETER(volumeN, double)
+
+
+class named_constructableN
+{
+public:
+ // a macro could extend the number of parameters if desired
+ template<typename FM0, typename FM1, typename FM2>
+ named_constructableN(const FM0 &a0, const FM1 &a1, const FM2 &a2)
+ {
+ label = (a0, a1, a2)[labelN];
+ size = (a0, a1, a2)[sizeN];
+ volume = (a0, a1, a2)[volumeN];
+ }
+ std::string label;
+ int size;
+ double volume;
+};
+
+
+BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(test_multi_param_construction,N) )
+{
+ named_constructableN constructed(labelN = "hello", sizeN = 1, volumeN = 1.0);
+ BOOST_CHECK_EQUAL(constructed.label, "hello");
+ BOOST_CHECK_EQUAL(constructed.size, 1);
+ BOOST_CHECK_EQUAL(constructed.volume, 1.0);
+
+}
\ No newline at end of file

Added: sandbox/guigl/libs/guigl/test/test_parameter_compilation.cpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/test/test_parameter_compilation.cpp 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,13 @@
+#include <boost/parameter/keyword.hpp>
+#include <boost/parameter/name.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/cat.hpp>
+
+using namespace boost;
+
+#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 20, <libs/guigl/test/test_parameter_compilation.hpp>))
+ #include BOOST_PP_ITERATE()

Added: sandbox/guigl/libs/guigl/test/test_parameter_compilation.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/test/test_parameter_compilation.hpp 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,39 @@
+#define N BOOST_PP_ITERATION()
+
+#define labelN BOOST_PP_CAT(label,N)
+#define sizeN BOOST_PP_CAT(size,N)
+#define volumeN BOOST_PP_CAT(volume,N)
+#define _labelN BOOST_PP_CAT(_label,N)
+#define _sizeN BOOST_PP_CAT(_size,N)
+#define _volumeN BOOST_PP_CAT(_volume,N)
+
+#define named_constructableN BOOST_PP_CAT(named_constructable,N)
+
+BOOST_PARAMETER_NAME(labelN)
+BOOST_PARAMETER_NAME(sizeN)
+BOOST_PARAMETER_NAME(volumeN)
+
+class named_constructableN
+{
+public:
+ template<typename FM0, typename FM1, typename FM2>
+ named_constructableN(const FM0 &a0, const FM1 &a1, const FM2 &a2)
+ {
+ label = (a0, a1, a2)[_labelN];
+ size = (a0, a1, a2)[_sizeN];
+ volume = (a0, a1, a2)[_volumeN];
+ }
+ std::string label;
+ int size;
+ double volume;
+};
+
+
+BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(test_multi_param_construction,N) )
+{
+ named_constructableN constructed(_labelN = "hello", _sizeN = 1, _volumeN = 1.0);
+ BOOST_CHECK_EQUAL(constructed.label, "hello");
+ BOOST_CHECK_EQUAL(constructed.size, 1);
+ BOOST_CHECK_EQUAL(constructed.volume, 1.0);
+
+}
\ No newline at end of file

Added: sandbox/guigl/libs/guigl/test/test_parameter_dispatch_compilation.cpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/test/test_parameter_dispatch_compilation.cpp 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,15 @@
+#include <boost/parameter/keyword.hpp>
+#include <boost/parameter/name.hpp>
+#include <boost/parameter/preprocessor.hpp>
+
+#define BOOST_TEST_MAIN
+#include <boost/test/unit_test.hpp>
+
+#include <boost/preprocessor/iteration/iterate.hpp>
+#include <boost/preprocessor/cat.hpp>
+
+using namespace boost;
+
+#define BOOST_PP_ITERATION_PARAMS_1 (3, (0, 20, <libs/guigl/test/test_parameter_dispatch_compilation.hpp>))
+ #include BOOST_PP_ITERATE()
+

Added: sandbox/guigl/libs/guigl/test/test_parameter_dispatch_compilation.hpp
==============================================================================
--- (empty file)
+++ sandbox/guigl/libs/guigl/test/test_parameter_dispatch_compilation.hpp 2008-08-14 01:16:37 EDT (Thu, 14 Aug 2008)
@@ -0,0 +1,48 @@
+#define N BOOST_PP_ITERATION()
+
+#define labelN BOOST_PP_CAT(label,N)
+#define sizeN BOOST_PP_CAT(size,N)
+#define volumeN BOOST_PP_CAT(volume,N)
+#define _labelN BOOST_PP_CAT(_label,N)
+#define _sizeN BOOST_PP_CAT(_size,N)
+#define _volumeN BOOST_PP_CAT(_volume,N)
+
+#define named_constructable_implN BOOST_PP_CAT(named_constructable_impl,N)
+#define named_constructableN BOOST_PP_CAT(named_constructable,N)
+
+BOOST_PARAMETER_NAME(labelN)
+BOOST_PARAMETER_NAME(sizeN)
+BOOST_PARAMETER_NAME(volumeN)
+
+struct named_constructable_implN
+{
+ template <class ArgumentPack>
+ named_constructable_implN(ArgumentPack const& args)
+ {
+ label = args[_labelN];
+ size = args[_sizeN];
+ volume = args[_volumeN];
+ }
+
+ std::string label;
+ int size;
+ double volume;
+};
+
+class named_constructableN : public named_constructable_implN
+{
+public:
+ BOOST_PARAMETER_CONSTRUCTOR(
+ named_constructableN, (named_constructable_implN), tag
+ , (required (labelN,*) (sizeN,*) (volumeN,*)) )
+};
+
+
+BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(test_multi_param_construction,N) )
+{
+ named_constructableN constructed(_labelN = "hello", _sizeN = 1, _volumeN = 1.0);
+ BOOST_CHECK_EQUAL(constructed.label, "hello");
+ BOOST_CHECK_EQUAL(constructed.size, 1);
+ BOOST_CHECK_EQUAL(constructed.volume, 1.0);
+
+}
\ No newline at end of file


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