Compare commits

..

1 Commits

Author SHA1 Message Date
nobody
6c8db244a4 This commit was manufactured by cvs2svn to create branch
'thread_rewrite'.

[SVN r30953]
2005-09-13 14:20:32 +00:00
98 changed files with 382 additions and 13602 deletions

View File

@@ -1,136 +0,0 @@
# Copyright 2016 Edward Diener
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
sudo: false
python: "2.7"
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
addons:
apt:
packages:
- libstdc++-5-dev
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-libc++
env: TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z
addons:
apt:
packages:
- libc++-dev
- os: osx
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- git submodule update --init libs/parameter_python
- cp -r $TRAVIS_BUILD_DIR/* libs/parameter
- python tools/boostdep/depinst/depinst.py parameter
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 --verbose-test libs/config/test//config_info toolset=$TOOLSET cxxstd=$CXXSTD || true
- ./b2 -j3 libs/parameter/test toolset=$TOOLSET cxxstd=$CXXSTD
notifications:
email:
on_success: always

View File

@@ -1,37 +0,0 @@
# Copyright 2017 Edward Diener
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0,msvc-12.0,msvc-14.0
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1
install:
- cd ..
- git clone -b %APPVEYOR_REPO_BRANCH% https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/build
- git submodule update --init libs/config
- git submodule update --init tools/boostdep
- git submodule update --init libs/parameter_python
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\parameter
- python tools/boostdep/depinst/depinst.py parameter
- bootstrap
- b2 headers
build: off
test_script:
- b2 libs/parameter/test toolset=%TOOLSET%

View File

@@ -1,30 +0,0 @@
# Copyright David Abrahams 2006. 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 docutils ;
sources = [ glob *.rst ] ;
bases = $(sources:S=) ;
# This is a path relative to the html/ subdirectory where the
# generated output will eventually be moved.
stylesheet = "--stylesheet=rst.css" ;
for local b in $(bases)
{
html $(b) : $(b).rst :
#
<docutils-html>"-gdt --link-stylesheet --traceback --trim-footnote-reference-space --footnote-references=superscript "$(stylesheet)
;
}
alias htmls : $(bases) ;
stage html : $(bases) ;
###############################################################################
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : html ;
explicit boostrelease ;

View File

@@ -1,17 +0,0 @@
.. -*-rst-*-
.. Copyright David Abrahams 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)
To build the html::
bjam html
To test the code in this documentation:
.. parsed-literal::
python ../../../tools/litre/tool.py `pwd`/index.rst --dump_dir=../test/literate
cd ../test/literate
bjam

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,43 +0,0 @@
/* Copyright David Abrahams 2006. 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 "../../../../rst.css";
div.section div.section div.section dl {
margin-left: 2em;
}
td span {
vertical-align: text-top;
}
img {
border: none;
vertical-align: middle
}
span.vellipsis {
display: block;
width: 5px;
height: 22px;
background: url("vellipsis.gif");
margin-left: 3em;
text-indent: -1000px;
}
PRE
{
FONT-FAMILY: monospace ;
}
CODE
{
FONT-FAMILY: monospace;
}
.pre
{
FONT-FAMILY: monospace;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 B

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

5
include/boost/parameter.hpp Normal file → Executable file
View File

@@ -3,19 +3,14 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
// See www.boost.org/libs/parameter for documentation.
#ifndef BOOST_PARAMETER_050401_HPP
#define BOOST_PARAMETER_050401_HPP
#include <boost/parameter/parameters.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/parameter/binding.hpp>
#include <boost/parameter/value_type.hpp>
#include <boost/parameter/macros.hpp>
#include <boost/parameter/match.hpp>
#include <boost/parameter/name.hpp>
#include <boost/parameter/preprocessor.hpp>
#endif // BOOST_PARAMETER_050401_HPP

234
include/boost/parameter/aux_/arg_list.hpp Normal file → Executable file
View File

@@ -6,36 +6,25 @@
#ifndef ARG_LIST_050329_HPP
#define ARG_LIST_050329_HPP
#include <boost/mpl/apply.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/facilities/intercept.hpp>
#include <boost/parameter/aux_/void.hpp>
#include <boost/parameter/aux_/result_of0.hpp>
#include <boost/parameter/aux_/default.hpp>
#include <boost/parameter/aux_/parameter_requirements.hpp>
#include <boost/parameter/aux_/yesno.hpp>
#include <boost/parameter/aux_/is_maybe.hpp>
#include <boost/parameter/config.hpp>
#include <boost/mpl/apply.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/begin.hpp>
#include <boost/mpl/end.hpp>
#include <boost/mpl/iterator_tags.hpp>
#include <boost/type_traits/add_reference.hpp>
#include <boost/type_traits/is_same.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;
namespace aux {
// Tag type passed to MPL lambda.
struct lambda_tag;
//
// Structures used to build the tuple of actual arguments. The
// tuple is a nested cons-style list of arg_list specializations
@@ -46,14 +35,10 @@ struct lambda_tag;
// declarations to build member function overload sets that can
// match against keywords.
//
// MPL sequence support
struct arg_list_tag;
// Terminates arg_list<> and represents an empty list. Since this
// is just the terminating case you might want to look at arg_list
// first, to get a feel for what's really happening here.
struct empty_arg_list
{
empty_arg_list() {}
@@ -71,22 +56,20 @@ struct empty_arg_list
// lookup given that default
struct binding
{
template<class KW, class Default, class Reference>
template<class KW, class Default>
struct apply
{
typedef Default type;
};
};
// Terminator for has_key, indicating that the keyword is unique
template <class KW>
static no_tag has_key(KW*);
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#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
@@ -137,46 +120,23 @@ struct empty_arg_list
// was found if we match this overload, so unless that parameter
// has a default, we indicate that the actual arguments don't
// match the function's requirements.
template <class ParameterRequirements, class ArgPack>
template <class ParameterRequirements>
static typename ParameterRequirements::has_default
satisfies(ParameterRequirements*, ArgPack*);
// MPL sequence support
typedef empty_arg_list type; // convenience
typedef arg_list_tag tag; // For dispatching to sequence intrinsics
satisfies(ParameterRequirements*);
};
// Forward declaration for arg_list::operator,
template <class KW, class T>
struct tagged_argument;
template <class T>
struct get_reference
{
typedef typename T::reference type;
};
// A tuple of tagged arguments, terminated with empty_arg_list.
// Every TaggedArg is an instance of tagged_argument<>.
template <class TaggedArg, class Next = empty_arg_list>
struct arg_list : Next
{
typedef arg_list<TaggedArg,Next> self;
typedef typename TaggedArg::key_type key_type;
typedef typename is_maybe<typename TaggedArg::value_type>::type holds_maybe;
typedef typename mpl::eval_if<
holds_maybe
, get_reference<typename TaggedArg::value_type>
, get_reference<TaggedArg>
>::type reference;
typedef typename mpl::if_<
holds_maybe
, reference
, typename TaggedArg::value_type
>::type value_type;
typedef typename TaggedArg::value_type value_type;
typedef typename TaggedArg::reference reference;
TaggedArg arg; // Stores the argument
@@ -184,12 +144,12 @@ struct arg_list : Next
template< // class A0, class A1, ...
BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, class A)
>
arg_list( // A0& a0, A1& a1, ...
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PARAMETER_MAX_ARITY, A, & a)
arg_list( // A0 const& a0, A1 const& a1, ...
BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PARAMETER_MAX_ARITY, A, const & a)
)
: Next( // a1, a2, ...
BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PARAMETER_MAX_ARITY, a)
, void_reference()
, void_()
)
, arg(a0)
{}
@@ -197,59 +157,36 @@ struct arg_list : Next
// 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 head, Next const& tail)
arg_list(TaggedArg arg, Next const& tail)
: Next(tail)
, arg(head)
, arg(arg)
{}
// A metafunction class that, given a keyword and a default
// type, returns the appropriate result type for a keyword
// lookup given that default
struct binding
{
template <class KW, class Default, class Reference>
template <class KW, class Default>
struct apply
{
typedef typename mpl::eval_if<
boost::is_same<KW, key_type>
, mpl::if_<Reference, reference, value_type>
, mpl::apply_wrap3<typename Next::binding, KW, Default, Reference>
, mpl::identity<reference>
, mpl::apply_wrap2<typename Next::binding, KW, Default>
>::type type;
};
};
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// Overload for key_type, so the assert below will fire if the
// same keyword is used again
static yes_tag has_key(key_type*);
using Next::has_key;
BOOST_MPL_ASSERT_MSG(
sizeof(Next::has_key((key_type*)0)) == sizeof(no_tag)
, duplicate_keyword, (key_type)
);
#endif
//
// Begin implementation of indexing operators for looking up
// specific arguments by name
//
// Helpers that handle the case when TaggedArg is
// empty<T>.
template <class D>
reference get_default(D const&, mpl::false_) const
{
return arg.value;
}
template <class D>
reference get_default(D const& d, mpl::true_) const
{
return arg.value ? arg.value.get() : arg.value.construct(d.value);
}
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \
|| BOOST_WORKAROUND(__GNUC__, < 3) \
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// These older compilers don't support the overload set creation
// idiom well, so we need to do all the return type calculation
// for the compiler and dispatch through an outer function template
@@ -273,7 +210,7 @@ struct arg_list : Next
// Outer indexing operators that dispatch to the right node's
// get() function.
template <class KW>
typename mpl::apply_wrap3<binding, KW, void_, mpl::true_>::type
typename mpl::apply_wrap2<binding, KW, void_>::type
operator[](keyword<KW> const& x) const
{
typename mpl::apply_wrap1<key_owner, KW>::type const& sublist = *this;
@@ -281,7 +218,7 @@ struct arg_list : Next
}
template <class KW, class Default>
typename mpl::apply_wrap3<binding, KW, Default&, mpl::true_>::type
typename mpl::apply_wrap2<binding, KW, Default&>::type
operator[](default_<KW, Default> x) const
{
typename mpl::apply_wrap1<key_owner, KW>::type const& sublist = *this;
@@ -289,10 +226,9 @@ struct arg_list : Next
}
template <class KW, class F>
typename mpl::apply_wrap3<
typename mpl::apply_wrap2<
binding,KW
, typename result_of0<F>::type
, mpl::true_
>::type
operator[](lazy_default<KW,F> x) const
{
@@ -304,42 +240,39 @@ struct arg_list : Next
// reached, indicating no matching argument was passed, the
// default is returned, or if no default_ or lazy_default was
// passed, compilation fails.
reference get(keyword<key_type> const&) const
{
BOOST_MPL_ASSERT_NOT((holds_maybe));
return arg.value;
}
template <class Default>
reference get(default_<key_type,Default> const& d) const
{
return get_default(d, holds_maybe());
}
template <class Default>
reference get(lazy_default<key_type, Default>) const
reference get(keyword<key_type> const& x) const
{
return arg.value;
}
template <class Default>
reference get(default_<key_type,Default> x) const
{
return arg.value;
}
template <class Default>
reference get(lazy_default<key_type, Default> x) const
{
return arg.value;
}
#else
reference operator[](keyword<key_type> const&) const
reference operator[](keyword<key_type> const& x) const
{
BOOST_MPL_ASSERT_NOT((holds_maybe));
return arg.value;
}
template <class Default>
reference operator[](default_<key_type, Default> const& d) const
reference operator[](default_<key_type, Default> x) const
{
return get_default(d, holds_maybe());
return arg.value;
}
template <class Default>
reference operator[](lazy_default<key_type, Default>) const
reference operator[](lazy_default<key_type, Default> x) const
{
BOOST_MPL_ASSERT_NOT((holds_maybe));
return arg.value;
}
@@ -359,14 +292,10 @@ struct arg_list : Next
// compile-time computation and never really called, so a
// declaration is enough.
//
template <class HasDefault, class Predicate, class ArgPack>
static typename mpl::apply_wrap2<
typename mpl::lambda<Predicate, lambda_tag>::type
, value_type, ArgPack
>::type
template <class HasDefault, class Predicate>
static typename mpl::apply1<Predicate, value_type>::type
satisfies(
parameter_requirements<key_type,Predicate,HasDefault>*
, ArgPack*
);
// Builds an overload set including satisfies functions defined
@@ -374,64 +303,23 @@ struct arg_list : Next
using Next::satisfies;
#endif
#if !BOOST_WORKAROUND(__BORLANDC__,BOOST_TESTED_AT(0x564))
// 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>
operator,(tagged_argument<KW,T2> x) const
arg_list<tagged_argument<KW, T2>, arg_list>
operator,(tagged_argument<KW, T2> x) const
{
return arg_list<tagged_argument<KW,T2>, self>(x, *this);
return arg_list<tagged_argument<KW, T2>, arg_list>(x, *this);
}
// MPL sequence support
typedef self type; // Convenience for users
typedef Next tail_type; // For the benefit of iterators
typedef arg_list_tag tag; // For dispatching to sequence intrinsics
#endif
};
// MPL sequence support
template <class ArgumentPack>
struct arg_list_iterator
{
typedef mpl::forward_iterator_tag category;
#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // ETI workaround
template <> struct arg_list<int,int> {};
#endif
// The incremented iterator
typedef arg_list_iterator<typename ArgumentPack::tail_type> next;
// dereferencing yields the key type
typedef typename ArgumentPack::key_type type;
};
template <>
struct arg_list_iterator<empty_arg_list> {};
}} // namespace parameter::aux
// MPL sequence support
namespace mpl
{
template <>
struct begin_impl<parameter::aux::arg_list_tag>
{
template <class S>
struct apply
{
typedef parameter::aux::arg_list_iterator<S> type;
};
};
template <>
struct end_impl<parameter::aux::arg_list_tag>
{
template <class>
struct apply
{
typedef parameter::aux::arg_list_iterator<parameter::aux::empty_arg_list> type;
};
};
}
} // namespace boost
}}} // namespace boost::parameter::aux
#endif // ARG_LIST_050329_HPP

View File

@@ -1,141 +0,0 @@
// Copyright Daniel Wallin 2006. 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_CAST_060902_HPP
# define BOOST_PARAMETER_CAST_060902_HPP
# include <boost/detail/workaround.hpp>
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# include <boost/type_traits/add_reference.hpp>
# include <boost/type_traits/remove_const.hpp>
# endif
namespace boost { namespace parameter { namespace aux {
struct use_default_tag {};
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate) value
# else
// Handles possible implicit casts. Used by preprocessor.hpp to
// normalize user input.
//
// cast<void*>::execute() is identity
// cast<void*(X)>::execute() is identity
// cast<void(X)>::execute() casts to X
//
// preprocessor.hpp uses this like this:
//
// #define X(value, predicate)
// cast<void predicate>::execute(value)
//
// X(something, *)
// X(something, *(predicate))
// X(something, (int))
template <class T, class Args>
struct cast;
template <class Args>
struct cast<void*, Args>
{
static use_default_tag execute(use_default_tag)
{
return use_default_tag();
}
static use_default_tag remove_const(use_default_tag)
{
return use_default_tag();
}
template <class U>
static U& execute(U& value)
{
return value;
}
template <class U>
static U& remove_const(U& x)
{
return x;
}
};
#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
typedef void* voidstar;
template <class T, class Args>
struct cast<voidstar(T), Args>
: cast<void*, Args>
{
};
#else
template <class T, class Args>
struct cast<void*(T), Args>
: cast<void*, Args>
{
};
#endif
// This is a hack used in cast<> to turn the user supplied type,
// which may or may not be a placeholder expression into one, so
// that it will be properly evaluated by mpl::apply.
template <class T, class Dummy = mpl::_1>
struct as_placeholder_expr
{
typedef T type;
};
template <class T, class Args>
struct cast<void(T), Args>
{
typedef typename mpl::apply2<
as_placeholder_expr<T>, Args, Args>::type type0;
typedef typename boost::add_reference<
typename boost::remove_const<type0>::type
>::type reference;
static use_default_tag execute(use_default_tag)
{
return use_default_tag();
}
static use_default_tag remove_const(use_default_tag)
{
return use_default_tag();
}
static type0 execute(type0 value)
{
return value;
}
template <class U>
static reference remove_const(U const& x)
{
return const_cast<reference>(x);
}
};
# define BOOST_PARAMETER_FUNCTION_CAST(value, predicate, args) \
boost::parameter::aux::cast<void predicate, args>::remove_const( \
boost::parameter::aux::cast<void predicate, args>::execute(value) \
)
# endif
}}} // namespace boost::parameter::aux
#endif // BOOST_PARAMETER_CAST_060902_HPP

14
include/boost/parameter/aux_/default.hpp Normal file → Executable file
View File

@@ -4,9 +4,7 @@
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef DEFAULT_050329_HPP
# define DEFAULT_050329_HPP
# include <boost/detail/workaround.hpp>
#define DEFAULT_050329_HPP
namespace boost { namespace parameter { namespace aux {
@@ -29,7 +27,7 @@ struct default_
// the user when resolving the value of the parameter with the
// given keyword
//
# if BOOST_WORKAROUND(__EDG_VERSION__, <= 300)
#if BOOST_WORKAROUND(__EDG_VERSION__, <= 300)
// These compilers need a little extra help with overload
// resolution; we have empty_arg_list's operator[] accept a base
// class to make that overload less preferable.
@@ -50,8 +48,8 @@ struct lazy_default
: lazy_default_base<KW,DefaultComputer>(x)
{}
};
# define BOOST_PARAMETER_lazy_default_fallback lazy_default_base
# else
# define BOOST_PARAMETER_lazy_default_fallback lazy_default_base
#else
template <class KW, class DefaultComputer>
struct lazy_default
{
@@ -60,8 +58,8 @@ struct lazy_default
{}
DefaultComputer const& compute_default;
};
# define BOOST_PARAMETER_lazy_default_fallback lazy_default
# endif
# define BOOST_PARAMETER_lazy_default_fallback lazy_default
#endif
}}} // namespace boost::parameter::aux

View File

@@ -1,26 +0,0 @@
// 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

View File

@@ -1,120 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
//
// 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/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 {
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
{
typedef typename add_reference<
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
T const
# else
typename add_const<T>::type
# endif
>::type reference;
typedef typename remove_cv<
BOOST_DEDUCED_TYPENAME remove_reference<reference>::type
>::type non_cv_value;
explicit maybe(T value_)
: value(value_)
, constructed(false)
{}
maybe()
: constructed(false)
{}
~maybe()
{
if (constructed)
this->destroy();
}
reference construct(reference value_) const
{
return value_;
}
template <class U>
reference construct2(U const& value_) const
{
new (m_storage.address()) non_cv_value(value_);
constructed = true;
return *(non_cv_value*)m_storage.address();
}
template <class U>
reference construct(U const& value_) const
{
return this->construct2(value_);
}
void destroy()
{
((non_cv_value*)m_storage.address())->~non_cv_value();
}
typedef reference(maybe<T>::*safe_bool)() const;
operator safe_bool() const
{
return value ? &maybe<T>::get : 0 ;
}
reference get() const
{
return value.get();
}
private:
boost::optional<T> value;
mutable bool constructed;
mutable typename referent_storage<
reference
>::type m_storage;
};
}}} // namespace boost::parameter::aux
#endif // BOOST_PARAMETER_MAYBE_060211_HPP

35
include/boost/parameter/aux_/overloads.hpp Normal file → Executable file
View File

@@ -44,40 +44,29 @@
#define N BOOST_PP_ITERATION()
#define BOOST_PARAMETER_open_list(z, n, text) \
aux::item< \
aux::make_arg_list< \
BOOST_PP_CAT(PS, n), BOOST_PP_CAT(A, n)
#define BOOST_PARAMETER_close_list(z, n, text) >
#define BOOST_PARAMETER_arg_list(n) \
aux::make_arg_list< \
BOOST_PP_ENUM(N, BOOST_PARAMETER_open_list, _) \
, void_ \
BOOST_PP_REPEAT(N, BOOST_PARAMETER_close_list, _) \
, deduced_list \
, aux::tag_keyword_arg \
>
#define BOOST_PARAMETER_arg_pack_init(z, n, limit) \
BOOST_PP_CAT(a, BOOST_PP_SUB(limit,n))
mpl::apply_wrap1< \
BOOST_PP_ENUM(N, BOOST_PARAMETER_open_list, _) \
, mpl::always<aux::empty_arg_list> \
BOOST_PP_REPEAT(N, BOOST_PARAMETER_close_list, _) \
, unnamed_list>
template<BOOST_PP_ENUM_PARAMS(N, class A)>
typename mpl::first<
typename BOOST_PARAMETER_arg_list(N)::type
>::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, & a)) const
typename BOOST_PARAMETER_arg_list(N)::type
operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, const& a)) const
{
typedef typename BOOST_PARAMETER_arg_list(N)::type result;
typedef typename BOOST_PARAMETER_arg_list(N)::type arg_tuple;
typedef typename mpl::first<result>::type result_type;
typedef typename mpl::second<result>::type error;
error();
return result_type(
BOOST_PP_ENUM(N, BOOST_PARAMETER_arg_pack_init, BOOST_PP_DEC(N))
return arg_tuple(
BOOST_PP_ENUM_PARAMS(N, a)
BOOST_PP_ENUM_TRAILING_PARAMS(
BOOST_PP_SUB(BOOST_PARAMETER_MAX_ARITY, N)
, aux::void_reference() BOOST_PP_INTERCEPT
, aux::void_() BOOST_PP_INTERCEPT
));
}

View File

View File

@@ -1,35 +0,0 @@
// Copyright David Abrahams 2006. 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_PARAMETER_AUX_PARENTHESIZED_TYPE_DWA2006414_HPP
# define BOOST_PARAMETER_AUX_PARENTHESIZED_TYPE_DWA2006414_HPP
# include <boost/config.hpp>
# include <boost/detail/workaround.hpp>
namespace boost { namespace parameter { namespace aux {
// A macro that takes a parenthesized C++ type name (T) and transforms
// it into an un-parenthesized type expression equivalent to T.
# define BOOST_PARAMETER_PARENTHESIZED_TYPE(x) \
boost::parameter::aux::unaryfunptr_arg_type< void(*)x >::type
// A metafunction that transforms void(*)(T) -> T
template <class UnaryFunctionPointer>
struct unaryfunptr_arg_type;
template <class Arg>
struct unaryfunptr_arg_type<void(*)(Arg)>
{
typedef Arg type;
};
template <>
struct unaryfunptr_arg_type<void(*)(void)>
{
typedef void type;
};
}}} // namespace boost::parameter::aux
#endif // BOOST_PARAMETER_AUX_PARENTHESIZED_TYPE_DWA2006414_HPP

View File

@@ -1,115 +0,0 @@
// Copyright Daniel Wallin 2005. 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_FLATTEN_051217_HPP
# define BOOST_PARAMETER_FLATTEN_051217_HPP
# include <boost/preprocessor/tuple/elem.hpp>
# include <boost/preprocessor/tuple/rem.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/seq/for_each.hpp>
# include <boost/preprocessor/seq/for_each_i.hpp>
# include <boost/preprocessor/identity.hpp>
# include <boost/preprocessor/selection/max.hpp>
# include <boost/preprocessor/arithmetic/sub.hpp>
# include <boost/preprocessor/repetition/enum_trailing.hpp>
# include <boost/parameter/aux_/preprocessor/for_each.hpp>
# define BOOST_PARAMETER_FLATTEN_SPLIT_required required,
# define BOOST_PARAMETER_FLATTEN_SPLIT_optional optional,
# define BOOST_PARAMETER_FLATTEN_SPLIT_deduced deduced,
# define BOOST_PARAMETER_FLATTEN_SPLIT(sub) \
BOOST_PP_CAT(BOOST_PARAMETER_FLATTEN_SPLIT_, sub)
# define BOOST_PARAMETER_FLATTEN_QUALIFIER(sub) \
BOOST_PP_SPLIT(0, BOOST_PARAMETER_FLATTEN_SPLIT(sub))
# define BOOST_PARAMETER_FLATTEN_ARGS(sub) \
BOOST_PP_SPLIT(1, BOOST_PARAMETER_FLATTEN_SPLIT(sub))
# define BOOST_PARAMETER_FLATTEN_ARITY_optional(arities) \
BOOST_PP_TUPLE_ELEM(3,0,arities)
# define BOOST_PARAMETER_FLATTEN_ARITY_required(arities) \
BOOST_PP_TUPLE_ELEM(3,1,arities)
# define BOOST_PARAMETER_FLATTEN_SPEC0_DUMMY_ELEM(z, n, data) ~
# define BOOST_PARAMETER_FLATTEN_SPEC0(r, n, elem, data) \
(( \
BOOST_PP_TUPLE_ELEM(3,2,data) \
, BOOST_PP_TUPLE_REM(BOOST_PP_TUPLE_ELEM(3,0,data)) elem \
BOOST_PP_ENUM_TRAILING( \
BOOST_PP_SUB( \
BOOST_PP_TUPLE_ELEM(3,1,data) \
, BOOST_PP_TUPLE_ELEM(3,0,data) \
) \
, BOOST_PARAMETER_FLATTEN_SPEC0_DUMMY_ELEM \
, ~ \
) \
))
# define BOOST_PARAMETER_FLATTEN_SPEC_AUX(r, arity, max_arity, spec, transform) \
BOOST_PARAMETER_FOR_EACH_R( \
r \
, arity \
, BOOST_PARAMETER_FLATTEN_ARGS(spec) \
, (arity, max_arity, transform(BOOST_PARAMETER_FLATTEN_QUALIFIER(spec))) \
, BOOST_PARAMETER_FLATTEN_SPEC0 \
)
# define BOOST_PARAMETER_FLATTEN_IDENTITY(x) x
# define BOOST_PARAMETER_FLATTEN_SPEC_optional(r, arities, spec) \
BOOST_PARAMETER_FLATTEN_SPEC_AUX( \
r \
, BOOST_PP_CAT( \
BOOST_PARAMETER_FLATTEN_ARITY_, BOOST_PARAMETER_FLATTEN_QUALIFIER(spec) \
)(arities) \
, BOOST_PP_TUPLE_ELEM(3,2,arities) \
, spec \
, BOOST_PARAMETER_FLATTEN_IDENTITY \
)
# define BOOST_PARAMETER_FLATTEN_SPEC_required(r, arities, spec) \
BOOST_PARAMETER_FLATTEN_SPEC_optional(r, arities, spec)
# define BOOST_PARAMETER_FLATTEN_SPEC_AS_DEDUCED(x) BOOST_PP_CAT(deduced_,x)
# define BOOST_PARAMETER_FLATTEN_SPEC_deduced_M(r, arities, n, spec) \
BOOST_PARAMETER_FLATTEN_SPEC_AUX( \
r \
, BOOST_PP_CAT( \
BOOST_PARAMETER_FLATTEN_ARITY_, BOOST_PARAMETER_FLATTEN_QUALIFIER(spec) \
)(arities) \
, BOOST_PP_TUPLE_ELEM(3,2,arities) \
, spec \
, BOOST_PARAMETER_FLATTEN_SPEC_AS_DEDUCED \
)
# define BOOST_PARAMETER_FLATTEN_SPEC_deduced(r, arities, spec) \
BOOST_PP_SEQ_FOR_EACH_I_R( \
r \
, BOOST_PARAMETER_FLATTEN_SPEC_deduced_M \
, arities \
, BOOST_PARAMETER_FLATTEN_ARGS(spec) \
)
# define BOOST_PARAMETER_FLATTEN_SPEC(r, arities, spec) \
BOOST_PP_CAT( \
BOOST_PARAMETER_FLATTEN_SPEC_, BOOST_PARAMETER_FLATTEN_QUALIFIER(spec) \
)(r, arities, spec)
# define BOOST_PARAMETER_FLATTEN(optional_arity, required_arity, wanted_arity, specs) \
BOOST_PP_SEQ_FOR_EACH( \
BOOST_PARAMETER_FLATTEN_SPEC \
, ( \
optional_arity, required_arity \
, wanted_arity \
) \
, specs \
)
#endif // BOOST_PARAMETER_FLATTEN_051217_HPP

View File

@@ -1,103 +0,0 @@
// Copyright Daniel Wallin 2005. 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_FOR_EACH_051217_HPP
# define BOOST_PARAMETER_FOR_EACH_051217_HPP
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/detail/split.hpp>
# include <boost/preprocessor/logical/not.hpp>
# include <boost/preprocessor/facilities/is_empty.hpp>
# include <boost/preprocessor/tuple/eat.hpp>
# include <boost/preprocessor/arithmetic/inc.hpp>
# include <boost/preprocessor/repeat.hpp>
# include <boost/preprocessor/punctuation/comma_if.hpp>
# include <boost/preprocessor/for.hpp>
# include <boost/preprocessor/repetition/deduce_r.hpp>
# define BOOST_PARAMETER_FOR_EACH_head_aux2(x,y) (x,y), ~
# define BOOST_PARAMETER_FOR_EACH_head_aux3(x,y,z) (x,y,z), ~
# define BOOST_PARAMETER_FOR_EACH_head_aux4(x,y,z,u) (x,y,z,u), ~
# define BOOST_PARAMETER_FOR_EACH_head(n,x) \
BOOST_PP_SPLIT(0, BOOST_PP_CAT(BOOST_PARAMETER_FOR_EACH_head_aux,n) x)
# define BOOST_PARAMETER_FOR_EACH_pred_aux_BOOST_PARAMETER_FOR_EACH_END_SENTINEL
# define BOOST_PARAMETER_FOR_EACH_pred_aux_check(x) \
BOOST_PP_NOT(BOOST_PP_IS_EMPTY( \
BOOST_PP_CAT(BOOST_PARAMETER_FOR_EACH_pred_aux_, x) \
)), ~
# define BOOST_PARAMETER_FOR_EACH_pred_aux2(x,y) \
BOOST_PARAMETER_FOR_EACH_pred_aux_check(x)
# define BOOST_PARAMETER_FOR_EACH_pred_aux3(x,y,z) \
BOOST_PARAMETER_FOR_EACH_pred_aux_check(x)
# define BOOST_PARAMETER_FOR_EACH_pred_aux4(x,y,z,u) \
BOOST_PARAMETER_FOR_EACH_pred_aux_check(x)
# define BOOST_PARAMETER_FOR_EACH_pred_aux0(n,x) \
BOOST_PP_CAT(BOOST_PARAMETER_FOR_EACH_pred_aux,n) x
# if BOOST_PP_CONFIG_FLAGS() & BOOST_PP_CONFIG_MSVC()
# define BOOST_PARAMETER_FOR_EACH_pred_SPLIT_FIRST(x) \
BOOST_PP_SPLIT(0, x)
# define BOOST_PARAMETER_FOR_EACH_pred(r, state) \
BOOST_PARAMETER_FOR_EACH_pred_SPLIT_FIRST( \
BOOST_PARAMETER_FOR_EACH_pred_aux0( \
BOOST_PP_TUPLE_ELEM(5,3,state) \
, BOOST_PP_TUPLE_ELEM(5,0,state) \
) \
)
# else
# define BOOST_PARAMETER_FOR_EACH_pred(r, state) \
BOOST_PP_SPLIT( \
0 \
, BOOST_PARAMETER_FOR_EACH_pred_aux0( \
BOOST_PP_TUPLE_ELEM(5,3,state) \
, BOOST_PP_TUPLE_ELEM(5,0,state) \
) \
)
# endif
# define BOOST_PARAMETER_FOR_EACH_op(r, state) \
( \
BOOST_PP_TUPLE_EAT(BOOST_PP_TUPLE_ELEM(5,3,state)) \
BOOST_PP_TUPLE_ELEM(5,0,state) \
, BOOST_PP_TUPLE_ELEM(5,1,state) \
, BOOST_PP_TUPLE_ELEM(5,2,state) \
, BOOST_PP_TUPLE_ELEM(5,3,state) \
, BOOST_PP_INC(BOOST_PP_TUPLE_ELEM(5,4,state)) \
)
# define BOOST_PARAMETER_FOR_EACH_macro(r, state) \
BOOST_PP_TUPLE_ELEM(5,2,state)( \
r \
, BOOST_PP_TUPLE_ELEM(5,4,state) \
, BOOST_PARAMETER_FOR_EACH_head( \
BOOST_PP_TUPLE_ELEM(5,3,state) \
, BOOST_PP_TUPLE_ELEM(5,0,state) \
) \
, BOOST_PP_TUPLE_ELEM(5,1,state) \
)
# define BOOST_PARAMETER_FOR_EACH_build_end_sentinel(z,n,text) \
BOOST_PP_COMMA_IF(n) BOOST_PARAMETER_FOR_EACH_END_SENTINEL
# define BOOST_PARAMETER_FOR_EACH_build_end_sentinel_tuple(arity) \
( \
BOOST_PP_REPEAT(arity, BOOST_PARAMETER_FOR_EACH_build_end_sentinel, _) \
)
# define BOOST_PARAMETER_FOR_EACH_R(r, arity, list, data, macro) \
BOOST_PP_CAT(BOOST_PP_FOR_, r)( \
(list BOOST_PARAMETER_FOR_EACH_build_end_sentinel_tuple(arity), data, macro, arity, 0) \
, BOOST_PARAMETER_FOR_EACH_pred \
, BOOST_PARAMETER_FOR_EACH_op \
, BOOST_PARAMETER_FOR_EACH_macro \
)
# define BOOST_PARAMETER_FOR_EACH(arity, list, data, macro) \
BOOST_PARAMETER_FOR_EACH_R(BOOST_PP_DEDUCE_R(), arity, list, data, macro)
#endif // BOOST_PARAMETER_FOR_EACH_051217_HPP

0
include/boost/parameter/aux_/result_of0.hpp Normal file → Executable file
View File

View File

@@ -1,66 +0,0 @@
// Copyright Daniel Wallin 2006. 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_SET_060912_HPP
# define BOOST_PARAMETER_SET_060912_HPP
# include <boost/detail/workaround.hpp>
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# include <boost/mpl/insert.hpp>
# include <boost/mpl/set/set0.hpp>
# include <boost/mpl/has_key.hpp>
namespace boost { namespace parameter { namespace aux {
typedef mpl::set0<> set0;
template <class Set, class K>
struct insert_
{
typedef typename mpl::insert<Set, K>::type type;
};
template <class Set, class K>
struct has_key_
{
typedef typename mpl::has_key<Set, K>::type type;
};
}}} // namespace boost::parameter::aux
# else
# include <boost/mpl/list.hpp>
# include <boost/mpl/end.hpp>
# include <boost/mpl/find.hpp>
# include <boost/mpl/not.hpp>
# include <boost/mpl/push_front.hpp>
namespace boost { namespace parameter { namespace aux {
typedef mpl::list0<> set0;
template <class Set, class K>
struct insert_
{
typedef typename mpl::push_front<Set, K>::type type;
};
template <class Set, class K>
struct has_key_
{
typedef typename mpl::find<Set, K>::type iter;
typedef mpl::not_<
is_same<iter, typename mpl::end<Set>::type>
> type;
};
}}} // namespace boost::parameter::aux
# endif
#endif // BOOST_PARAMETER_SET_060912_HPP

4
include/boost/parameter/aux_/tag.hpp Normal file → Executable file
View File

@@ -5,10 +5,12 @@
# define BOOST_PARAMETER_AUX_TAG_DWA2005610_HPP
# include <boost/parameter/aux_/unwrap_cv_reference.hpp>
# include <boost/parameter/aux_/tagged_argument.hpp>
namespace boost { namespace parameter { namespace aux {
template <class Keyword, class Arg>
struct tagged_argument;
template <class Keyword, class ActualArg
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
, class = typename is_cv_reference_wrapper<ActualArg>::type

152
include/boost/parameter/aux_/tagged_argument.hpp Normal file → Executable file
View File

@@ -3,32 +3,19 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PARAMETER_TAGGED_ARGUMENT_050328_HPP
# define BOOST_PARAMETER_TAGGED_ARGUMENT_050328_HPP
#ifndef TAGGED_ARGUMENT_050328_HPP
#define TAGGED_ARGUMENT_050328_HPP
# include <boost/parameter/aux_/void.hpp>
# include <boost/parameter/aux_/arg_list.hpp>
# include <boost/parameter/aux_/result_of0.hpp>
# include <boost/mpl/if.hpp>
# include <boost/mpl/apply_wrap.hpp>
# include <boost/mpl/and.hpp>
# include <boost/mpl/not.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/type_traits/is_convertible.hpp>
# include <boost/type_traits/is_reference.hpp>
#include <boost/parameter/aux_/void.hpp>
#include <boost/parameter/aux_/arg_list.hpp>
namespace boost { namespace parameter { namespace aux {
struct empty_arg_list;
struct arg_list_tag;
struct tagged_argument_base {};
// Holds a reference to an argument of type Arg associated with
// keyword Keyword
template <class Keyword, class Arg>
struct tagged_argument : tagged_argument_base
struct tagged_argument
{
typedef Keyword key_type;
typedef Arg value_type;
@@ -36,22 +23,6 @@ struct tagged_argument : tagged_argument_base
tagged_argument(reference x) : value(x) {}
// A metafunction class that, given a keyword and a default
// type, returns the appropriate result type for a keyword
// lookup given that default
struct binding
{
template <class KW, class Default, class Reference>
struct apply
{
typedef typename mpl::eval_if<
boost::is_same<KW, key_type>
, mpl::if_<Reference, reference, value_type>
, mpl::identity<Default>
>::type type;
};
};
// Comma operator to compose argument list without using parameters<>.
// Useful for argument lists with undetermined length.
template <class Keyword2, class Arg2>
@@ -69,120 +40,15 @@ struct tagged_argument : tagged_argument_base
, arg_list<tagged_argument<Keyword2, Arg2> >(x, empty_arg_list())
);
}
reference operator[](keyword<Keyword> const&) const
{
return value;
}
# if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template <class KW, class Default>
Default& get_with_default(default_<KW,Default> const& x, int) const
{
return x.value;
}
template <class Default>
reference get_with_default(default_<key_type,Default> const&, long) const
{
return value;
}
template <class KW, class Default>
typename mpl::apply_wrap3<binding, KW, Default&, mpl::true_>::type
operator[](default_<KW,Default> const& x) const
{
return get_with_default(x, 0L);
}
template <class KW, class F>
typename result_of0<F>::type
get_with_lazy_default(lazy_default<KW,F> const& x, int) const
{
return x.compute_default();
}
template <class F>
reference get_with_lazy_default(lazy_default<key_type,F> const&, long) const
{
return value;
}
template <class KW, class F>
typename mpl::apply_wrap3<
binding,KW
, typename result_of0<F>::type
, mpl::true_
>::type
operator[](lazy_default<KW,F> const& x) const
{
return get_with_lazy_default(x, 0L);
}
# else
template <class Default>
reference operator[](default_<key_type,Default> const& ) const
{
return value;
}
template <class F>
reference operator[](lazy_default<key_type,F> const& ) const
{
return value;
}
template <class KW, class Default>
Default& operator[](default_<KW,Default> const& x) const
{
return x.value;
}
template <class KW, class F>
typename result_of0<F>::type operator[](lazy_default<KW,F> const& x) const
{
return x.compute_default();
}
template <class ParameterRequirements>
static typename ParameterRequirements::has_default
satisfies(ParameterRequirements*);
template <class HasDefault, class Predicate>
static typename mpl::apply1<Predicate, value_type>::type
satisfies(
parameter_requirements<key_type,Predicate,HasDefault>*
);
# endif
reference value;
# if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310))
// warning suppression
private:
void operator=(tagged_argument const&);
public:
# endif
// MPL sequence support
typedef tagged_argument type; // Convenience for users
typedef empty_arg_list tail_type; // For the benefit of iterators
typedef arg_list_tag tag; // For dispatching to sequence intrinsics
};
// Defines a metafunction, is_tagged_argument, that identifies
// tagged_argument specializations and their derived classes.
template <class T>
struct is_tagged_argument_aux
: is_convertible<T*,tagged_argument_base const*>
{};
template <class T>
struct is_tagged_argument
: mpl::and_<
mpl::not_<is_reference<T> >
, is_tagged_argument_aux<T>
>
{};
// tagged_argument specializations.
BOOST_PYTHON_IS_XXX_DEF(tagged_argument,tagged_argument,2)
}}} // namespace boost::parameter::aux
#endif // BOOST_PARAMETER_TAGGED_ARGUMENT_050328_HPP
#endif // TAGGED_ARGUMENT_050328_HPP

View File

@@ -1,47 +0,0 @@
// Copyright Daniel Wallin 2006. 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_TEMPLATE_KEYWORD_060203_HPP
# define BOOST_PARAMETER_TEMPLATE_KEYWORD_060203_HPP
# include <boost/mpl/and.hpp>
# include <boost/mpl/not.hpp>
# include <boost/type_traits/is_convertible.hpp>
# include <boost/type_traits/is_reference.hpp>
namespace boost { namespace parameter {
namespace aux
{
struct template_keyword_tag {};
template <class T, class U>
struct is_pointer_convertible
: is_convertible<T*, U*>
{};
template <class T>
struct is_template_keyword
: mpl::and_<
mpl::not_<is_reference<T> >
, is_pointer_convertible<T, template_keyword_tag>
>
{};
} // namespace aux
template <class Tag, class T>
struct template_keyword
: aux::template_keyword_tag
{
typedef Tag key_type;
typedef T value_type;
typedef value_type reference;
};
}} // namespace boost::parameter
#endif // BOOST_PARAMETER_TEMPLATE_KEYWORD_060203_HPP

6
include/boost/parameter/aux_/unwrap_cv_reference.hpp Normal file → Executable file
View File

@@ -44,6 +44,12 @@ struct is_cv_reference_wrapper
value> type;
};
#if BOOST_WORKAROUND(MSVC, == 1200)
template <>
struct is_cv_reference_wrapper<int>
: mpl::false_ {};
#endif
// Needed for unwrap_cv_reference below. T might be const, so
// eval_if might fail because of deriving from T const on EDG.
template <class T>

21
include/boost/parameter/aux_/void.hpp Normal file → Executable file
View File

@@ -3,27 +3,16 @@
// accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#ifndef BOOST_PARAMETER_VOID_050329_HPP
#define BOOST_PARAMETER_VOID_050329_HPP
#ifndef VOID_050329_HPP
#define VOID_050329_HPP
namespace boost { namespace parameter {
namespace boost { namespace parameter { namespace aux {
// A placemarker for "no argument passed."
// MAINTAINER NOTE: Do not make this into a metafunction
struct void_ {};
namespace aux
{
}}} // namespace boost::parameter::aux
inline void_& void_reference()
{
static void_ instance;
return instance;
}
} // namespace aux
}} // namespace boost::parameter
#endif // BOOST_PARAMETER_VOID_050329_HPP
#endif // VOID_050329_HPP

0
include/boost/parameter/aux_/yesno.hpp Normal file → Executable file
View File

65
include/boost/parameter/binding.hpp Normal file → Executable file
View File

@@ -5,59 +5,37 @@
# define BOOST_PARAMETER_BINDING_DWA200558_HPP
# include <boost/mpl/apply.hpp>
# include <boost/mpl/assert.hpp>
# include <boost/mpl/and.hpp>
# include <boost/parameter/aux_/result_of0.hpp>
# include <boost/parameter/aux_/void.hpp>
# include <boost/type_traits/is_same.hpp>
# include <boost/parameter/aux_/void.hpp>
# if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
# include <boost/parameter/aux_/void.hpp>
# include <boost/type_traits/is_same.hpp>
# endif
namespace boost { namespace parameter {
// A metafunction that, given an argument pack, returns the type of
// the parameter identified by the given keyword. If no such
// parameter has been specified, returns Default
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template <class Parameters, class Keyword, class Default>
struct binding0
{
typedef typename mpl::apply_wrap3<
typename Parameters::binding,Keyword,Default,mpl::true_
>::type type;
BOOST_MPL_ASSERT_NOT((
mpl::and_<
is_same<Default, void_>
, is_same<type, void_>
>
));
};
# endif
template <class Parameters, class Keyword, class Default = void_>
# if !BOOST_WORKAROUND(BOOST_MSVC, < 1300)
template <class Parameters, class Keyword, class Default = void>
struct binding
: mpl::apply_wrap2<
typename Parameters::binding,Keyword,Default
>
{};
# else
template <class Parameters, class Keyword, class Default = aux::void_>
struct binding
{
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
typedef typename mpl::eval_if<
mpl::is_placeholder<Parameters>
, mpl::identity<int>
, binding0<Parameters,Keyword,Default>
typedef typename mpl::apply_wrap2<
typename Parameters::binding,Keyword,
typename mpl::if_<is_same<Default,aux::void_>,void,Default>::type
>::type type;
# else
typedef typename mpl::apply_wrap3<
typename Parameters::binding,Keyword,Default,mpl::true_
>::type type;
BOOST_MPL_ASSERT_NOT((
mpl::and_<
is_same<Default, void_>
, is_same<type, void_>
>
));
# endif
BOOST_MPL_AUX_LAMBDA_SUPPORT(3,binding,(Parameters,Keyword,Default))
};
# endif
// A metafunction that, given an argument pack, returns the type of
// the parameter identified by the given keyword. If no such
@@ -66,11 +44,10 @@ struct binding
template <class Parameters, class Keyword, class DefaultFn>
struct lazy_binding
{
typedef typename mpl::apply_wrap3<
typedef typename mpl::apply_wrap2<
typename Parameters::binding
, Keyword
, typename aux::result_of0<DefaultFn>::type
, mpl::true_
>::type type;
};

2
include/boost/parameter/config.hpp Normal file → Executable file
View File

@@ -7,7 +7,7 @@
#define BOOST_PARAMETER_CONFIG_050403_HPP
#ifndef BOOST_PARAMETER_MAX_ARITY
# define BOOST_PARAMETER_MAX_ARITY 8
# define BOOST_PARAMETER_MAX_ARITY 5
#endif
#endif // BOOST_PARAMETER_CONFIG_050403_HPP

55
include/boost/parameter/keyword.hpp Normal file → Executable file
View File

@@ -9,6 +9,7 @@
#include <boost/parameter/aux_/unwrap_cv_reference.hpp>
#include <boost/parameter/aux_/tag.hpp>
#include <boost/parameter/aux_/default.hpp>
#include <boost/noncopyable.hpp>
namespace boost { namespace parameter {
@@ -28,10 +29,10 @@ namespace boost { namespace parameter {
// f(rate = 1, skew = 2.4);
//
template <class Tag>
struct keyword
struct keyword : noncopyable
{
template <class T>
typename aux::tag<Tag, T>::type const
typename aux::tag<Tag, T>::type
operator=(T& x) const
{
typedef typename aux::tag<Tag, T>::type result;
@@ -52,17 +53,23 @@ struct keyword
return aux::lazy_default<Tag, Default>(default_);
}
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) // avoid partial ordering bugs
template <class T>
typename aux::tag<Tag, T const>::type const
typename aux::tag<Tag, T const>::type
operator=(T const& x) const
{
typedef typename aux::tag<Tag, T const>::type result;
return result(x);
}
#endif
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1300) // avoid partial ordering bugs
template <class Default>
aux::default_<Tag, const Default>
operator|(const Default& default_) const
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
volatile
#endif
{
return aux::default_<Tag, const Default>(default_);
}
@@ -70,9 +77,13 @@ struct keyword
template <class Default>
aux::lazy_default<Tag, Default>
operator||(Default const& default_) const
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
volatile
#endif
{
return aux::lazy_default<Tag, Default>(default_);
}
#endif
public: // Insurance against ODR violations
@@ -81,40 +92,26 @@ struct keyword
// every instantiation of a function template is the same object.
// We provide a reference to a common instance of each keyword
// object and prevent construction by users.
static keyword<Tag> const instance;
// This interface is deprecated
static keyword<Tag>& get()
{
return const_cast<keyword<Tag>&>(instance);
static keyword<Tag> result;
return result;
}
private:
keyword() {}
};
template <class Tag>
keyword<Tag> const keyword<Tag>::instance = {};
// Reduces boilerplate required to declare and initialize keywords
// without violating ODR. Declares a keyword tag type with the given
// name in namespace tag_namespace, and declares and initializes a
// reference in an anonymous namespace to a singleton instance of that
// type.
// name in namespace tag_namespace, and declares and initializes a
//
#define BOOST_PARAMETER_KEYWORD(tag_namespace,name) \
namespace tag_namespace { struct name; } \
::boost::parameter::keyword<tag_namespace::name>& name \
= ::boost::parameter::keyword<tag_namespace::name>::get();
#define BOOST_PARAMETER_KEYWORD(tag_namespace,name) \
namespace tag_namespace \
{ \
struct name \
{ \
static char const* keyword_name() \
{ \
return #name; \
} \
}; \
} \
namespace \
{ \
::boost::parameter::keyword<tag_namespace::name> const& name \
= ::boost::parameter::keyword<tag_namespace::name>::instance;\
}
}} // namespace boost::parameter

5
include/boost/parameter/macros.hpp Normal file → Executable file
View File

@@ -15,14 +15,13 @@
#include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/cat.hpp>
#include <boost/detail/workaround.hpp>
#define BOOST_PARAMETER_FUN_TEMPLATE_HEAD1(n) \
template<BOOST_PP_ENUM_PARAMS(n, class T)>
#define BOOST_PARAMETER_FUN_TEMPLATE_HEAD0(n)
#if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
#ifndef BOOST_NO_SFINAE
# define BOOST_PARAMETER_MATCH_TYPE(n, param) \
BOOST_PP_EXPR_IF(n, typename) param::match \
@@ -79,7 +78,7 @@
#define BOOST_PARAMETER_FUN(ret, name, lo, hi, parameters) \
\
template<class Params> \
ret BOOST_PP_CAT(name, _with_named_params)(Params const& p); \
ret BOOST_PP_CAT(name, _with_named_params)(Params const&); \
\
BOOST_PP_REPEAT_FROM_TO( \
lo, BOOST_PP_INC(hi), BOOST_PARAMETER_FUN_DECL, (ret, name, parameters)) \

2
include/boost/parameter/match.hpp Normal file → Executable file
View File

@@ -29,7 +29,7 @@
BOOST_PARAMETER_MAX_ARITY \
, BOOST_PP_SEQ_SIZE(ArgTypes) \
) \
, ::boost::parameter::void_ BOOST_PP_INTERCEPT \
, ::boost::parameter::aux::void_ BOOST_PP_INTERCEPT \
)
# else

View File

@@ -1,146 +0,0 @@
// Copyright Daniel Wallin 2006. 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_NAME_060806_HPP
# define BOOST_PARAMETER_NAME_060806_HPP
# include <boost/parameter/keyword.hpp>
# include <boost/parameter/value_type.hpp>
# include <boost/detail/workaround.hpp>
# include <boost/preprocessor/cat.hpp>
# include <boost/preprocessor/stringize.hpp>
# include <boost/preprocessor/control/iif.hpp>
# include <boost/preprocessor/tuple/eat.hpp>
# include <boost/preprocessor/tuple/elem.hpp>
# include <boost/mpl/placeholders.hpp>
# if !defined(BOOST_NO_SFINAE) \
&& !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
# include <boost/utility/enable_if.hpp>
# include <boost/mpl/lambda.hpp>
namespace boost { namespace parameter { namespace aux {
// Tag type passed to MPL lambda.
struct lambda_tag;
struct name_tag_base
{};
template <class Tag>
struct name_tag
{};
template <class T>
struct is_name_tag
: mpl::false_
{};
}}} // namespace boost::parameter::aux
namespace boost { namespace mpl {
template <class T>
struct lambda<
T
, typename boost::enable_if<
parameter::aux::is_name_tag<T>, parameter::aux::lambda_tag
>::type
>
{
typedef true_ is_le;
typedef bind3< quote3<parameter::value_type>, arg<2>, T, void> result_;
typedef result_ type;
};
}} // namespace boost::mpl
# endif
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# include <boost/preprocessor/detail/split.hpp>
// From Paul Mensonides
# define BOOST_PARAMETER_IS_BINARY(x) \
BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_BINARY_C x BOOST_PP_COMMA() 0) \
/**/
# define BOOST_PARAMETER_IS_BINARY_C(x,y) \
~, 1 BOOST_PP_RPAREN() \
BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ \
/**/
# else
# include <boost/preprocessor/detail/is_binary.hpp>
# define BOOST_PARAMETER_IS_BINARY(x) BOOST_PP_IS_BINARY(x)
# endif
# define BOOST_PARAMETER_BASIC_NAME(tag_namespace, tag, name) \
namespace tag_namespace \
{ \
struct tag \
{ \
static char const* keyword_name() \
{ \
return BOOST_PP_STRINGIZE(tag); \
} \
\
typedef boost::parameter::value_type< \
boost::mpl::_2, tag, boost::parameter::void_ \
> _; \
\
typedef boost::parameter::value_type< \
boost::mpl::_2, tag, boost::parameter::void_ \
> _1; \
}; \
} \
namespace \
{ \
::boost::parameter::keyword<tag_namespace::tag> const& name \
= ::boost::parameter::keyword<tag_namespace::tag>::instance; \
}
# define BOOST_PARAMETER_COMPLEX_NAME_TUPLE1(tag,namespace) \
(tag, namespace), ~
# define BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name) \
BOOST_PP_TUPLE_ELEM(2, 0, (BOOST_PARAMETER_COMPLEX_NAME_TUPLE1 name))
# define BOOST_PARAMETER_COMPLEX_NAME_TAG(name) \
BOOST_PP_TUPLE_ELEM(2, 0, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
# define BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
BOOST_PP_TUPLE_ELEM(2, 1, BOOST_PARAMETER_COMPLEX_NAME_TUPLE(name))
# define BOOST_PARAMETER_COMPLEX_NAME(name) \
BOOST_PARAMETER_BASIC_NAME( \
BOOST_PARAMETER_COMPLEX_NAME_NAMESPACE(name) \
, BOOST_PP_TUPLE_EAT(2) name \
, BOOST_PARAMETER_COMPLEX_NAME_TAG(name) \
) \
/**/
# define BOOST_PARAMETER_SIMPLE_NAME(name) \
BOOST_PARAMETER_BASIC_NAME(tag, name, BOOST_PP_CAT(_, name))
# define BOOST_PARAMETER_NAME(name) \
BOOST_PP_IIF( \
BOOST_PARAMETER_IS_BINARY(name) \
, BOOST_PARAMETER_COMPLEX_NAME \
, BOOST_PARAMETER_SIMPLE_NAME \
)(name) \
/**/
# define BOOST_PARAMETER_TEMPLATE_KEYWORD(name) \
namespace tag \
{ \
struct name; \
} \
template <class T> \
struct name \
: boost::parameter::template_keyword<tag::name, T> \
{}; \
/**/
#endif // BOOST_PARAMETER_NAME_060806_HPP

805
include/boost/parameter/parameters.hpp Normal file → Executable file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,82 +0,0 @@
// Copyright Daniel Wallin 2006. 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_VALUE_TYPE_060921_HPP
# define BOOST_PARAMETER_VALUE_TYPE_060921_HPP
# include <boost/mpl/apply.hpp>
# include <boost/mpl/assert.hpp>
# include <boost/mpl/and.hpp>
# include <boost/parameter/aux_/result_of0.hpp>
# include <boost/parameter/aux_/void.hpp>
# include <boost/type_traits/is_same.hpp>
namespace boost { namespace parameter {
// A metafunction that, given an argument pack, returns the type of
// the parameter identified by the given keyword. If no such
// parameter has been specified, returns Default
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
template <class Parameters, class Keyword, class Default>
struct value_type0
{
typedef typename mpl::apply_wrap3<
typename Parameters::binding,Keyword,Default,mpl::false_
>::type type;
BOOST_MPL_ASSERT_NOT((
mpl::and_<
is_same<Default, void_>
, is_same<type, void_>
>
));
};
# endif
template <class Parameters, class Keyword, class Default = void_>
struct value_type
{
# if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
typedef typename mpl::eval_if<
mpl::is_placeholder<Parameters>
, mpl::identity<int>
, value_type0<Parameters,Keyword,Default>
>::type type;
# else
typedef typename mpl::apply_wrap3<
typename Parameters::binding,Keyword,Default,mpl::false_
>::type type;
BOOST_MPL_ASSERT_NOT((
mpl::and_<
is_same<Default, void_>
, is_same<type, void_>
>
));
# endif
BOOST_MPL_AUX_LAMBDA_SUPPORT(3,value_type,(Parameters,Keyword,Default))
};
// A metafunction that, given an argument pack, returns the type of
// the parameter identified by the given keyword. If no such
// parameter has been specified, returns the type returned by invoking
// DefaultFn
template <class Parameters, class Keyword, class DefaultFn>
struct lazy_value_type
{
typedef typename mpl::apply_wrap3<
typename Parameters::binding
, Keyword
, typename aux::result_of0<DefaultFn>::type
, mpl::false_
>::type type;
};
}} // namespace boost::parameter
#endif // BOOST_PARAMETER_VALUE_TYPE_060921_HPP

View File

@@ -1,12 +0,0 @@
<!-- Copyright David Abrahams 2005. 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) -->
<html>
<head>
<meta http-equiv="refresh" content="0; URL=doc/html/index.html">
</head>
<body>
Automatically loading index page... if nothing happens, please go to
<a href="doc/html/index.html">doc/html/index.html</a>.
</body>
</html>

View File

@@ -1,17 +0,0 @@
{
"key": "parameter",
"name": "Parameter",
"authors": [
"David Abrahams",
"Daniel Wallin"
],
"description": "Boost.Parameter Library - Write functions that accept arguments by name.",
"category": [
"Emulation",
"Programming"
],
"maintainers": [
"David Abrahams <dave -at- boost-consulting.com>",
"Daniel Wallin <daniel -at- boostpro.com>"
]
}

View File

@@ -1,38 +0,0 @@
# Copyright David Abrahams, Daniel Wallin 2006. 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 Parameter Library test Jamfile
import python ;
project boost/parameter
: default-build <warnings>off
;
build-project literate ;
test-suite "parameter"
: [ run basics.cpp ]
[ run sfinae.cpp ]
[ run macros.cpp ]
[ run earwicker.cpp ]
[ run tutorial.cpp ]
[ run singular.cpp ]
[ run mpl.cpp ]
[ run preprocessor.cpp ]
[ run preprocessor_deduced.cpp ]
[ run efficiency.cpp : : : : : <variant>release ]
[ run maybe.cpp ]
[ run deduced.cpp ]
[ run optional_deduced_sfinae.cpp ]
[ run deduced_dependent_predicate.cpp ]
[ run normalized_argument_types.cpp ]
[ compile ntp.cpp ]
[ compile unwrap_cv_reference.cpp ]
[ compile-fail duplicates.cpp ]
[ compile-fail deduced_unmatched_arg.cpp ]
[ compile compose.cpp ]
[ bpl-test python_test ]
;

View File

@@ -1,112 +0,0 @@
// Copyright David Abrahams, Daniel Wallin 2003. 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)
#include <boost/parameter.hpp>
#include <cassert>
#include <string.h>
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include "basics.hpp"
namespace test
{
// A separate function for getting the "value" key, so we can deduce
// F and use lazy_binding on it.
template <class Params, class F>
typename boost::parameter::lazy_binding<Params,tag::value,F>::type
extract_value(Params const& p, F const& f)
{
typename boost::parameter::lazy_binding<
Params, tag::value, F
>::type v = p[value || f ];
return v;
}
template<class Params>
int f_impl(Params const& p)
{
typename boost::parameter::binding<Params, tag::name>::type
n = p[name];
typename boost::parameter::binding<
Params, tag::value, double
>::type v = extract_value(p, boost::bind(&value_default));
typename boost::parameter::binding<
Params, tag::index, int
>::type i =
#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
p[test::index | 999];
#else
p[index | 999];
#endif
p[tester](n,v,i);
return 1;
}
template<class Tester, class Name, class Value, class Index>
int f(Tester const& t, const Name& name_,
const Value& value_, const Index& index_)
{
return f_impl(f_parameters()(t, name_, value_, index_));
}
template<class Tester, class Name, class Value>
int f(Tester const& t, const Name& name_, const Value& value_)
{
return f_impl(f_parameters()(t, name_, value_));
}
template<class Tester, class Name>
int f(Tester const& t, const Name& name_)
{
return f_impl(f_parameters()(t, name_));
}
template<class Params>
int f_list(Params const& params)
{
return f_impl(params);
}
}
int main()
{
using test::f;
using test::f_list;
using test::name;
using test::value;
using test::index;
using test::tester;
f(
test::values(S("foo"), S("bar"), S("baz"))
, S("foo"), S("bar"), S("baz")
);
int x = 56;
f(
test::values("foo", 666.222, 56)
, index = boost::ref(x), name = "foo"
);
#if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
// No comma operator available on Borland
f_list((
tester = test::values("foo", 666.222, 56)
, index = boost::ref(x)
, name = "foo"
));
#endif
//f(index = 56, name = 55); // won't compile
return boost::report_errors();
}

View File

@@ -1,112 +0,0 @@
// Copyright David Abrahams, Daniel Wallin 2005. 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 BASICS_050424_HPP
#define BASICS_050424_HPP
#include <boost/parameter/keyword.hpp>
#include <boost/parameter/parameters.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/assert.hpp>
#include <boost/mpl/assert.hpp>
#include <cstring>
#include <boost/detail/lightweight_test.hpp>
namespace test {
BOOST_PARAMETER_KEYWORD(tag, name)
BOOST_PARAMETER_KEYWORD(tag, value)
BOOST_PARAMETER_KEYWORD(tag, index)
BOOST_PARAMETER_KEYWORD(tag, tester)
using namespace boost::parameter;
struct f_parameters // vc6 is happier with inheritance than with a typedef
: parameters<
tag::tester
, tag::name
, tag::value
, tag::index
>
{};
inline double value_default()
{
return 666.222;
}
template <class T>
inline bool equal(T const& x, T const& y)
{
return x == y;
}
inline bool equal(char const* s1, char const* s2)
{
using namespace std;
return !strcmp(s1,s2);
}
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
inline bool equal(char* s1, char* s2)
{
using namespace std;
return !strcmp(s1,s2);
}
#endif
template <class Name, class Value, class Index>
struct values_t
{
values_t(Name const& n, Value const& v, Index const& i)
: n(n), v(v), i(i)
{}
template <class Name_, class Value_, class Index_>
void operator()(Name_ const& n_, Value_ const& v_, Index_ const& i_) const
{
// Only VC and its emulators fail this; they seem to have
// problems with deducing the constness of string literal
// arrays.
#if defined(_MSC_VER) \
&& (BOOST_WORKAROUND(BOOST_INTEL_CXX_VERSION, <= 700) \
|| BOOST_WORKAROUND(BOOST_MSVC, < 1310)) \
|| BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# else
BOOST_MPL_ASSERT((boost::is_same<Index,Index_>));
BOOST_MPL_ASSERT((boost::is_same<Value,Value_>));
BOOST_MPL_ASSERT((boost::is_same<Name,Name_>));
#endif
BOOST_TEST(equal(n, n_));
BOOST_TEST(equal(v, v_));
BOOST_TEST(equal(i, i_));
}
Name const& n;
Value const& v;
Index const& i;
};
template <class Name, class Value, class Index>
inline values_t<Name,Value,Index>
values(Name const& n, Value const& v, Index const& i)
{
return values_t<Name,Value,Index>(n,v,i);
}
} // namespace test
// GCC2 has a problem with char (&)[] deduction, so we'll cast string
// literals there.
#undef S
#if BOOST_WORKAROUND(__GNUC__, == 2) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
# define S(s) (char const*)s
#else
# define S(s) s
#endif
#endif // BASICS_050424_HPP

View File

@@ -1,43 +0,0 @@
//~ Copyright Rene Rivera 2006.
//~ 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)
#include <boost/parameter.hpp>
namespace param
{
BOOST_PARAMETER_KEYWORD(Tag,a0)
BOOST_PARAMETER_KEYWORD(Tag,a1)
BOOST_PARAMETER_KEYWORD(Tag,a2)
}
namespace test
{
struct A
{
int i;
int j;
template <typename ArgPack> A(ArgPack const & args)
{
i = args[param::a0];
j = args[param::a1];
}
};
struct B : A
{
template <typename ArgPack> B(ArgPack const & args)
: A((args, param::a0 = 1))
{
}
};
}
int main()
{
test::A a((param::a0 = 1, param::a1 = 13, param::a2 = 6));
test::B b0((param::a1 = 13));
test::B b1((param::a1 = 13, param::a2 = 6));
}

View File

@@ -1,114 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <boost/parameter/parameters.hpp>
#include <boost/parameter/name.hpp>
#include <boost/parameter/binding.hpp>
#include "deduced.hpp"
namespace parameter = boost::parameter;
namespace mpl = boost::mpl;
BOOST_PARAMETER_NAME(x)
BOOST_PARAMETER_NAME(y)
BOOST_PARAMETER_NAME(z)
int main()
{
using namespace parameter;
check<
parameters<
tag::x
, tag::y
>
>(
(_x = 0, _y = 1)
, 0
, 1
);
check<
parameters<
tag::x
, required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
, optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
>
>(
(_x = 0, _y = not_present, _z = "foo")
, _x = 0
, "foo"
);
check<
parameters<
tag::x
, required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
, optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
>
>(
(_x = 0, _y = 1, _z = "foo")
, 0
, "foo"
, 1
);
check<
parameters<
tag::x
, required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
, optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
>
>(
(_x = 0, _y = 1, _z = "foo")
, 0
, 1
, "foo"
);
check<
parameters<
tag::x
, required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
, optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
>
>(
(_x = 0, _y = 1, _z = "foo")
, 0
, _y = 1
, "foo"
);
check<
parameters<
tag::x
, required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
, optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
>
>(
(_x = 0, _y = 1, _z = "foo")
, _z = "foo"
, _x = 0
, 1
);
// Fails becasue of parameters.hpp:428
/*
check<
parameters<
tag::x
, required<deduced<tag::y>, boost::is_convertible<mpl::_, int> >
, optional<deduced<tag::z>, boost::is_convertible<mpl::_, char const*> >
>
>(
(_x = 0, _y = 1, _z = "foo")
, _x = 0
, (long*)0
, 1
);
*/
return 0;
};

View File

@@ -1,77 +0,0 @@
// Copyright Daniel Wallin 2006. 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_DEDUCED_060920_HPP
# define BOOST_DEDUCED_060920_HPP
# include <boost/mpl/for_each.hpp>
# include "basics.hpp"
struct not_present_tag {};
not_present_tag not_present;
template <class E, class ArgPack>
struct assert_expected
{
assert_expected(E const& e, ArgPack const& args)
: expected(e)
, args(args)
{}
template <class T>
bool check_not_present(T const&) const
{
BOOST_MPL_ASSERT((boost::is_same<T,not_present_tag>));
return true;
}
template <class K>
bool check1(K const& k, not_present_tag const&, long) const
{
return check_not_present(args[k | not_present]);
}
template <class K, class Expected>
bool check1(K const& k, Expected const& expected, int) const
{
return test::equal(args[k], expected);
}
template <class K>
void operator()(K) const
{
boost::parameter::keyword<K> const& k = boost::parameter::keyword<K>::get();
assert(check1(k, expected[k], 0L));
}
E const& expected;
ArgPack const& args;
};
template <class E, class ArgPack>
void check0(E const& e, ArgPack const& args)
{
boost::mpl::for_each<E>(assert_expected<E,ArgPack>(e, args));
}
template <class P, class E, class A0>
void check(E const& e, A0 const& a0)
{
check0(e, P()(a0));
}
template <class P, class E, class A0, class A1>
void check(E const& e, A0 const& a0, A1 const& a1)
{
check0(e, P()(a0,a1));
}
template <class P, class E, class A0, class A1, class A2>
void check(E const& e, A0 const& a0, A1 const& a1, A2 const& a2)
{
check0(e, P()(a0,a1,a2));
}
#endif // BOOST_DEDUCED_060920_HPP

View File

@@ -1,109 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <boost/parameter/parameters.hpp>
#include <boost/parameter/name.hpp>
#include <boost/parameter/binding.hpp>
#include <boost/type_traits.hpp>
#include "deduced.hpp"
namespace parameter = boost::parameter;
namespace mpl = boost::mpl;
BOOST_PARAMETER_NAME(x)
BOOST_PARAMETER_NAME(y)
BOOST_PARAMETER_NAME(z)
int main()
{
using namespace parameter;
using boost::is_same;
using boost::remove_reference;
using boost::add_reference;
check<
parameters<
tag::x
, optional<
deduced<tag::y>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
, is_same<
mpl::_1
, remove_reference<binding<mpl::_2,tag::x> >
>
#else
, is_same<
add_reference<mpl::_1>
, binding<mpl::_2,tag::x>
>
#endif
>
>
>(
(_x = 0, _y = 1)
, 0
, 1
);
check<
parameters<
tag::x
, optional<
deduced<tag::y>
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
, is_same<
mpl::_1
, remove_reference<binding<mpl::_2,tag::x> >
>
#else
, is_same<
add_reference<mpl::_1>
, binding<mpl::_2,tag::x>
>
#endif
>
>
>(
(_x = 0U, _y = 1U)
, 0U
, 1U
);
check<
parameters<
tag::x
, optional<
deduced<tag::y>
, is_same<
mpl::_1
, tag::x::_
>
>
>
>(
(_x = 0U, _y = 1U)
, 0U
, 1U
);
check<
parameters<
tag::x
, optional<
deduced<tag::y>
, is_same<
mpl::_1
, tag::x::_1
>
>
>
>(
(_x = 0U, _y = 1U)
, 0U
, 1U
);
return 0;
}

View File

@@ -1,25 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <boost/parameter/parameters.hpp>
#include <boost/parameter/name.hpp>
namespace parameter = boost::parameter;
namespace mpl = boost::mpl;
BOOST_PARAMETER_NAME(x)
int main()
{
using namespace parameter;
using boost::is_convertible;
using mpl::_;
parameters<
optional<
deduced<tag::x>, is_convertible<_,int>
>
>()("foo");
}

View File

@@ -1,24 +0,0 @@
// Copyright Daniel Wallin 2005. 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)
#include <boost/parameter.hpp>
#include <string.h>
#include "basics.hpp"
namespace test
{
template <class Params>
void f(Params const &) {}
}
int main()
{
using namespace test;
f((name = 1, value = 1, test::index = 1, tester = 1,
value = 1 // repeated keyword: should not compile
));
return 0;
}

View File

@@ -1,56 +0,0 @@
// Copyright David Abrahams, Daniel Wallin 2005. 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)
#include <boost/parameter.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/mpl/placeholders.hpp>
#include <iostream>
namespace test {
BOOST_PARAMETER_KEYWORD(tag, x)
BOOST_PARAMETER_KEYWORD(tag, y)
BOOST_PARAMETER_KEYWORD(tag, z)
using namespace boost::parameter;
using namespace boost::mpl::placeholders;
struct f_parameters // vc6 is happier with inheritance than with a typedef
: parameters<
optional<tag::x,boost::is_convertible<_,int> >
, optional<tag::y,boost::is_convertible<_,int> >
, optional<tag::z,boost::is_convertible<_,int> >
>
{};
#ifdef BOOST_NO_VOID_RETURNS
BOOST_PARAMETER_FUN(int, f, 0, 3, f_parameters)
#else
BOOST_PARAMETER_FUN(void, f, 0, 3, f_parameters)
#endif
{
std::cout << "x = " << p[x | -1] << std::endl;
std::cout << "y = " << p[y | -2] << std::endl;
std::cout << "z = " << p[z | -3] << std::endl;
std::cout << "================" << std::endl;
#ifdef BOOST_NO_VOID_RETURNS
return 0;
#endif
}
}
int main()
{
using namespace test;
f(x = 1, y = 2, z = 3);
f(x = 1);
f(y = 2);
f(z = 3);
f(z = 3, x = 1);
}

View File

@@ -1,195 +0,0 @@
// Copyright David Abrahams, Matthias Troyer, Michael Gauckler
// 2005. 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/parameter.hpp>
#include <boost/timer.hpp>
#include <iostream>
namespace test
{
//
// This test measures the abstraction overhead of using the named
// parameter interface. Some actual test results have been recorded
// in timings.txt in this source file's directory, or
// http://www.boost.org/libs/parameter/test/timings.txt.
//
// Caveats:
//
// 1. This test penalizes the named parameter library slightly, by
// passing two arguments through the named interface, while
// only passing one through the plain C++ interface.
//
// 2. This test does not measure the case where an ArgumentPack is
// so large that it doesn't fit in the L1 cache.
//
// 3. Although we've tried to make this test as general as
// possible, we are targeting it at a specific application.
// Where that affects design decisions, we've noted it below in
// ***...***.
//
// 4. The first time you run this program, the time may not be
// representative because of disk and memory cache effects, so
// always run it multiple times and ignore the first
// measurement. This approach will also allow you to estimate
// the statistical error of your test by observing the
// variation in the valid times.
//
// 5. Try to run this program on a machine that's otherwise idle,
// or other processes and even device hardware interrupts may
// interfere by causing caches to be flushed.
// Accumulator function object with plain C++ interface
template <class T>
struct plain_weight_running_total
{
plain_weight_running_total()
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
: sum(T())
#else
: sum()
#endif
{}
void operator()(T w)
{
this->sum += w;
}
T sum;
};
BOOST_PARAMETER_KEYWORD(tag, weight)
BOOST_PARAMETER_KEYWORD(tag, value)
// Accumulator function object with named parameter interface
template <class T>
struct named_param_weight_running_total
{
named_param_weight_running_total()
#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
: sum(T())
#else
: sum()
#endif
{}
template <class ArgumentPack>
void operator()(ArgumentPack const& variates)
{
this->sum += variates[weight];
}
T sum;
};
// This value is required to ensure that a smart compiler's dead
// code elimination doesn't optimize away anything we're testing.
// We'll use it to compute the return code of the executable to make
// sure it's needed.
double live_code;
// Call objects of the given Accumulator type repeatedly with x as
// an argument.
template <class Accumulator, class Arg>
void hammer(Arg const& x, long const repeats)
{
// Strategy: because the sum in an accumulator after each call
// depends on the previous value of the sum, the CPU's pipeline
// might be stalled while waiting for the previous addition to
// complete. Therefore, we allocate an array of accumulators,
// and update them in sequence, so that there's no dependency
// between adjacent addition operations.
//
// Additionally, if there were only one accumulator, the
// compiler or CPU might decide to update the value in a
// register rather that writing it back to memory. we want each
// operation to at least update the L1 cache. *** Note: This
// concern is specific to the particular application at which
// we're targeting the test. ***
// This has to be at least as large as the number of
// simultaneous accumulations that can be executing in the
// compiler pipeline. A safe number here is larger than the
// machine's maximum pipeline depth. If you want to test the L2
// or L3 cache, or main memory, you can increase the size of
// this array. 1024 is an upper limit on the pipeline depth of
// current vector machines.
const std::size_t number_of_accumulators = 1024;
Accumulator a[number_of_accumulators];
for (long iteration = 0; iteration < repeats; ++iteration)
{
for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap)
{
(*ap)(x);
}
}
// Accumulate all the partial sums to avoid dead code
// elimination.
for (Accumulator* ap = a; ap < a + number_of_accumulators; ++ap)
{
live_code += ap->sum;
}
}
// Measure the time required to hammer accumulators of the given
// type with the argument x.
template <class Accumulator, class T>
double measure(T const& x, long const repeats)
{
// Hammer accumulators a couple of times to ensure the
// instruction cache is full of our test code, and that we don't
// measure the cost of a page fault for accessing the data page
// containing the memory where the accumulators will be
// allocated
hammer<Accumulator>(x, repeats);
hammer<Accumulator>(x, repeats);
// Now start a timer
boost::timer time;
hammer<Accumulator>(x, repeats); // This time, we'll measure
return time.elapsed();
}
}
int main()
{
using namespace test;
// first decide how many repetitions to measure
long repeats = 100;
double measured = 0;
while (measured < 1.0 && repeats <= 10000000)
{
repeats *= 10;
boost::timer time;
hammer<plain_weight_running_total<double> >(.1, repeats);
hammer<named_param_weight_running_total<double> >(
(weight = .1, value = .2), repeats);
measured = time.elapsed();
}
std::cout
<< "plain time: "
<< measure<plain_weight_running_total<double> >(.1, repeats)
<< std::endl;
std::cout
<< "named parameter time: "
<< measure<named_param_weight_running_total<double> >(
(weight = .1, value = .2), repeats
)
<< std::endl;
// This is ultimately responsible for preventing all the test code
// from being optimized away. Change this to return 0 and you
// unplug the whole test's life support system.
return live_code < 0.;
}

View File

@@ -1,33 +0,0 @@
import testing ;
run extracting-parameter-types0.cpp ;
run extracting-parameter-types1.cpp ;
compile template-keywords0.cpp ;
compile template-keywords1.cpp ;
compile top-level0.cpp ;
compile headers-and-namespaces0.cpp ;
compile predicate-requirements0.cpp ;
compile handling-out-parameters0.cpp ;
compile writing-the-function0.cpp ;
run building-argumentpacks0.cpp ;
compile defining-the-keywords0.cpp ;
compile defining-the-keywords1.cpp ;
compile exercising-the-code-so-far0.cpp ;
run lazy-default-computation0.cpp ;
run lazy-default-computation1.cpp ;
run namespaces0.cpp ;
run namespaces1.cpp ;
run namespaces2.cpp ;
run namespaces3.cpp ;
compile optional-parameters0.cpp ;
compile static-member-functions0.cpp ;
run parameter-enabled-constructors0.cpp ;
compile required-parameters0.cpp ;
compile class-template-skeleton0.cpp ;
compile deduced-template-parameters0.cpp ;
compile deduced-parameters0.cpp ;
compile default-expression-evaluation0.cpp ;
compile parameter-enabled-member-functions0.cpp ;
compile parameter-enabled-member-functions1.cpp ;
run fine-grained-name-control0.cpp ;

View File

@@ -1,6 +0,0 @@
These tests were extracted from the Boost.Parameter documentation
with:
python ../../../../tools/litre/tool.py \
../../../../libs/parameter/doc/index.rst \
--dump_dir=.

View File

@@ -1,47 +0,0 @@
#include <boost/parameter.hpp>
#include <iostream>
BOOST_PARAMETER_NAME(index)
template <class ArgumentPack>
int print_index(ArgumentPack const& args)
{
std::cout << "index = " << args[_index] << std::endl;
return 0;
}
int x = print_index(_index = 3); // prints "index = 3"
BOOST_PARAMETER_NAME(name)
template <class ArgumentPack>
int print_name_and_index(ArgumentPack const& args)
{
std::cout << "name = " << args[_name] << "; ";
return print_index(args);
}
int y = print_name_and_index((_index = 3, _name = "jones"));
namespace parameter = boost::parameter;
using parameter::required;
using parameter::optional;
using boost::is_convertible;
using boost::mpl::_;
parameter::parameters<
required<tag::name, is_convertible<_,char const*> >
, optional<tag::index, is_convertible<_,int> >
> spec;
char const sam[] = "sam";
int twelve = 12;
int z0 = print_name_and_index( spec(sam, twelve) );
int z1 = print_name_and_index(
spec(_index=12, _name="sam")
);
int main()
{}

View File

@@ -1,16 +0,0 @@
#include <boost/parameter.hpp>
namespace boost { namespace python {
template <
class A0
, class A1 = parameter::void_
, class A2 = parameter::void_
, class A3 = parameter::void_
>
struct class_
{
};
}}

View File

@@ -1,74 +0,0 @@
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(func)
BOOST_PARAMETER_NAME(docstring)
BOOST_PARAMETER_NAME(keywords)
BOOST_PARAMETER_NAME(policies)
struct default_call_policies
{};
struct no_keywords
{};
struct keywords
{};
template <class T>
struct is_keyword_expression
: boost::mpl::false_
{};
template <>
struct is_keyword_expression<keywords>
: boost::mpl::true_
{};
default_call_policies some_policies;
void f()
{}
namespace mpl = boost::mpl;
BOOST_PARAMETER_FUNCTION(
(void), def, tag,
(required (name,(char const*)) (func,*) ) // nondeduced
(deduced
(optional
(docstring, (char const*), "")
(keywords
, *(is_keyword_expression<mpl::_>) // see 5
, no_keywords())
(policies
, *(mpl::not_<
mpl::or_<
boost::is_convertible<mpl::_, char const*>
, is_keyword_expression<mpl::_> // see 5
>
>)
, default_call_policies()
)
)
)
)
{
}
int main()
{
def("f", &f, some_policies, "Documentation for f");
def("f", &f, "Documentation for f", some_policies);
def(
"f", &f
, _policies = some_policies, "Documentation for f");
}

View File

@@ -1,124 +0,0 @@
#include <boost/parameter.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/noncopyable.hpp>
#include <memory>
#include <boost/config.hpp>
using namespace boost::parameter;
using boost::mpl::_;
namespace boost { namespace python {
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
}}
namespace boost { namespace python {
namespace detail { struct bases_base {}; }
template <class A0 = void, class A1 = void, class A2 = void >
struct bases : detail::bases_base
{};
}}
#include <boost/type_traits/is_class.hpp>
namespace boost { namespace python {
typedef parameter::parameters<
required<tag::class_type, is_class<_> >
, parameter::optional<
deduced<tag::base_list>
, is_base_and_derived<detail::bases_base,_>
>
, parameter::optional<
deduced<tag::held_type>
, mpl::not_<
mpl::or_<
is_base_and_derived<detail::bases_base,_>
, is_same<noncopyable,_>
>
>
>
, parameter::optional<deduced<tag::copyable>, is_same<noncopyable,_> >
> class_signature;
template <
class A0
, class A1 = parameter::void_
, class A2 = parameter::void_
, class A3 = parameter::void_
>
struct class_
{
// Create ArgumentPack
typedef typename
class_signature::bind<A0,A1,A2,A3>::type
args;
// Extract first logical parameter.
typedef typename parameter::value_type<
args, tag::class_type>::type class_type;
typedef typename parameter::value_type<
args, tag::base_list, bases<> >::type base_list;
typedef typename parameter::value_type<
args, tag::held_type, class_type>::type held_type;
typedef typename parameter::value_type<
args, tag::copyable, void>::type copyable;
};
}}
struct B {};
struct D {};
using boost::python::bases;
typedef boost::python::class_<B, boost::noncopyable> c1;
#if defined(BOOST_NO_CXX11_SMART_PTR)
typedef boost::python::class_<D, std::auto_ptr<D>, bases<B> > c2;
#else
typedef boost::python::class_<D, std::unique_ptr<D>, bases<B> > c2;
#endif
BOOST_MPL_ASSERT((boost::is_same<c1::class_type, B>));
BOOST_MPL_ASSERT((boost::is_same<c1::base_list, bases<> >));
BOOST_MPL_ASSERT((boost::is_same<c1::held_type, B>));
BOOST_MPL_ASSERT((
boost::is_same<c1::copyable, boost::noncopyable>
));
BOOST_MPL_ASSERT((boost::is_same<c2::class_type, D>));
BOOST_MPL_ASSERT((boost::is_same<c2::base_list, bases<B> >));
#if defined(BOOST_NO_CXX11_SMART_PTR)
BOOST_MPL_ASSERT((
boost::is_same<c2::held_type, std::auto_ptr<D> >
));
#else
BOOST_MPL_ASSERT((
boost::is_same<c2::held_type, std::unique_ptr<D> >
));
#endif
BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));

View File

@@ -1,39 +0,0 @@
#include <boost/parameter.hpp>
#include <iostream>
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
#include <boost/graph/depth_first_search.hpp> // for dfs_visitor
BOOST_PARAMETER_FUNCTION(
(void), depth_first_search, tag
, (required
(graph, *)
(visitor, *)
(root_vertex, *)
(index_map, *)
(color_map, *)
)
)
{
std::cout << "graph=" << graph << std::endl;
std::cout << "visitor=" << visitor << std::endl;
std::cout << "root_vertex=" << root_vertex << std::endl;
std::cout << "index_map=" << index_map << std::endl;
std::cout << "color_map=" << color_map << std::endl;
}
int main()
{
depth_first_search(1, 2, 3, 4, 5);
depth_first_search(
"1", '2', _color_map = '5',
_index_map = "4", _root_vertex = "3");
}

View File

@@ -1,10 +0,0 @@
#include <boost/parameter/name.hpp>
namespace graphs
{
BOOST_PARAMETER_NAME(graph) // Note: no semicolon
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
}

View File

@@ -1,13 +0,0 @@
#include <boost/parameter/keyword.hpp>
namespace graphs
{
namespace tag { struct graph; } // keyword tag type
namespace // unnamed
{
// A reference to the keyword object
boost::parameter::keyword<tag::graph>& _graph
= boost::parameter::keyword<tag::graph>::get();
}
}

View File

@@ -1,118 +0,0 @@
#include <boost/parameter.hpp>
#include <boost/mpl/is_sequence.hpp>
#include <boost/noncopyable.hpp>
#include <boost/type_traits/is_class.hpp>
#include <memory>
#include <boost/config.hpp>
using namespace boost::parameter;
namespace boost { namespace python {
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
template <class B = int>
struct bases
{};
}}
namespace boost { namespace python {
using boost::mpl::_;
typedef parameter::parameters<
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;
}}
namespace boost { namespace python {
template <
class A0
, class A1 = parameter::void_
, class A2 = parameter::void_
, class A3 = parameter::void_
>
struct class_
{
// Create ArgumentPack
typedef typename
class_signature::bind<A0,A1,A2,A3>::type
args;
// Extract first logical parameter.
typedef typename parameter::value_type<
args, tag::class_type>::type class_type;
typedef typename parameter::value_type<
args, tag::base_list, bases<> >::type base_list;
typedef typename parameter::value_type<
args, tag::held_type, class_type>::type held_type;
typedef typename parameter::value_type<
args, tag::copyable, void>::type copyable;
};
}}
using boost::python::class_type;
using boost::python::copyable;
using boost::python::held_type;
using boost::python::base_list;
using boost::python::bases;
struct B {};
struct D {};
typedef boost::python::class_<
class_type<B>, copyable<boost::noncopyable>
> c1;
typedef boost::python::class_<
#if defined(BOOST_NO_CXX11_SMART_PTR)
D, held_type<std::auto_ptr<D> >, base_list<bases<B> >
#else
D, held_type<std::unique_ptr<D> >, base_list<bases<B> >
#endif
> c2;
BOOST_MPL_ASSERT((boost::is_same<c1::class_type, B>));
BOOST_MPL_ASSERT((boost::is_same<c1::base_list, bases<> >));
BOOST_MPL_ASSERT((boost::is_same<c1::held_type, B>));
BOOST_MPL_ASSERT((
boost::is_same<c1::copyable, boost::noncopyable>
));
BOOST_MPL_ASSERT((boost::is_same<c2::class_type, D>));
BOOST_MPL_ASSERT((boost::is_same<c2::base_list, bases<B> >));
#if defined(BOOST_NO_CXX11_SMART_PTR)
BOOST_MPL_ASSERT((
boost::is_same<c2::held_type, std::auto_ptr<D> >
));
#else
BOOST_MPL_ASSERT((
boost::is_same<c2::held_type, std::unique_ptr<D> >
));
#endif
BOOST_MPL_ASSERT((boost::is_same<c2::copyable, void>));

View File

@@ -1,28 +0,0 @@
#include <boost/parameter.hpp>
#include <cassert>
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
template <class Name, class Index>
int deduce_arg_types_impl(Name& name, Index& index)
{
Name& n2 = name; // we know the types
Index& i2 = index;
return index;
}
template <class ArgumentPack>
int deduce_arg_types(ArgumentPack const& args)
{
return deduce_arg_types_impl(args[_name], args[_index|42]);
}
int a1 = deduce_arg_types((_name = "foo"));
int a2 = deduce_arg_types((_name = "foo", _index = 3));
int main()
{
assert(a1 == 42);
assert(a2 == 3);
}

View File

@@ -1,21 +0,0 @@
#include <boost/parameter.hpp>
#include <boost/type_traits/remove_reference.hpp>
#include <cassert>
namespace parameter = boost::parameter;
BOOST_PARAMETER_NAME(index)
template <class ArgumentPack>
typename parameter::value_type<ArgumentPack, tag::index, int>::type
twice_index(ArgumentPack const& args)
{
return 2 * args[_index|42];
}
int six = twice_index(_index = 3);
int main()
{
assert(six == 6);
}

View File

@@ -1,15 +0,0 @@
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME((pass_foo, keywords) foo)
BOOST_PARAMETER_FUNCTION(
(int), f,
keywords, (required (foo, *)))
{
return foo + 1;
}
int x = f(pass_foo = 41);
int main()
{}

View File

@@ -1,30 +0,0 @@
#include <boost/parameter.hpp>
namespace boost
{
int vertex_index = 0;
template <class T = int>
struct dfs_visitor
{};
}
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
BOOST_PARAMETER_FUNCTION((void), f, tag,
(required (graph, *))
(optional
(visitor, *, boost::dfs_visitor<>())
(root_vertex, *, *vertices(graph).first)
(index_map, *, get(boost::vertex_index,graph))
(in_out(color_map), *,
default_color_map(num_vertices(graph), index_map) )
)
) {}

View File

@@ -1,3 +0,0 @@
#include <boost/parameter/keyword.hpp>
using boost::parameter::keyword;

View File

@@ -1,24 +0,0 @@
#include <boost/parameter.hpp>
#include <string>
namespace parameter = boost::parameter;
BOOST_PARAMETER_NAME(s1)
BOOST_PARAMETER_NAME(s2)
BOOST_PARAMETER_NAME(s3)
template <class ArgumentPack>
std::string f(ArgumentPack const& args)
{
std::string const& s1 = args[_s1];
std::string const& s2 = args[_s2];
typename parameter::binding<
ArgumentPack,tag::s3,std::string
>::type s3 = args[_s3|(s1+s2)]; // always constructs s1+s2
return s3;
}
std::string x = f((_s1="hello,", _s2=" world", _s3="hi world"));
int main()
{}

View File

@@ -1,30 +0,0 @@
#include <boost/bind.hpp>
#include <boost/ref.hpp>
#include <boost/parameter.hpp>
#include <string>
#include <functional>
namespace parameter = boost::parameter;
BOOST_PARAMETER_NAME(s1)
BOOST_PARAMETER_NAME(s2)
BOOST_PARAMETER_NAME(s3)
template <class ArgumentPack>
std::string f(ArgumentPack const& args)
{
std::string const& s1 = args[_s1];
std::string const& s2 = args[_s2];
typename parameter::binding<
ArgumentPack, tag::s3, std::string
>::type s3 = args[_s3
|| boost::bind(std::plus<std::string>(), boost::ref(s1), boost::ref(s2)) ];
return s3;
}
std::string x = f((_s1="hello,", _s2=" world", _s3="hi world"));
int main()
{}

View File

@@ -1,20 +0,0 @@
#include <boost/parameter.hpp>
#include <iostream>
namespace lib
{
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
BOOST_PARAMETER_FUNCTION(
(int), f, tag,
(optional (name,*,"bob")(index,(int),1))
)
{
std::cout << name << ":" << index << std::endl;
return index;
}
}
int x = lib::f(lib::_name = "jill", lib::_index = 1);
int main() {}

View File

@@ -1,23 +0,0 @@
#include <boost/parameter.hpp>
#include <iostream>
namespace lib
{
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
BOOST_PARAMETER_FUNCTION(
(int), f, tag,
(optional (name,*,"bob")(index,(int),1))
)
{
std::cout << name << ":" << index << std::endl;
return index;
}
}
using lib::_name;
using lib::_index;
int x = lib::f(_name = "jill", _index = 1);
int main() {}

View File

@@ -1,21 +0,0 @@
#include <boost/parameter.hpp>
#include <iostream>
namespace lib
{
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
BOOST_PARAMETER_FUNCTION(
(int), f, tag,
(optional (name,*,"bob")(index,(int),1))
)
{
std::cout << name << ":" << index << std::endl;
return index;
}
}
using namespace lib;
int x = f(_name = "jill", _index = 3);
int main() {}

View File

@@ -1,25 +0,0 @@
#include <boost/parameter.hpp>
#include <iostream>
namespace lib
{
namespace keywords
{
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
}
BOOST_PARAMETER_FUNCTION(
(int), f, keywords::tag,
(optional (name,*,"bob")(index,(int),1))
)
{
std::cout << name << ":" << index << std::endl;
return index;
}
}
using namespace lib::keywords;
int y = lib::f(_name = "bob", _index = 2);
int main() {}

View File

@@ -1,28 +0,0 @@
#include <boost/parameter.hpp>
namespace boost
{
int vertex_index = 0;
template <class T = int>
struct dfs_visitor
{};
}
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
BOOST_PARAMETER_FUNCTION((void), f, tag,
(required (graph, *))
(optional (visitor, *, boost::dfs_visitor<>())
(root_vertex, *, *vertices(graph).first)
(index_map, *, get(boost::vertex_index,graph))
(in_out(color_map), *,
default_color_map(num_vertices(graph), index_map) )
)
) {}

View File

@@ -1,31 +0,0 @@
#include <boost/parameter.hpp>
#include <iostream>
BOOST_PARAMETER_NAME(name)
BOOST_PARAMETER_NAME(index)
struct myclass_impl
{
template <class ArgumentPack>
myclass_impl(ArgumentPack const& args)
{
std::cout << "name = " << args[_name]
<< "; index = " << args[_index | 42]
<< std::endl;
}
};
struct myclass : myclass_impl
{
BOOST_PARAMETER_CONSTRUCTOR(
myclass, (myclass_impl), tag
, (required (name,*)) (optional (index,*))) // no semicolon
};
int main() {
myclass x("bob", 3); // positional
myclass y(_index = 12, _name = "sally"); // named
myclass z("june"); // positional/defaulted
}

View File

@@ -1,15 +0,0 @@
#include <boost/parameter.hpp>
#include <iostream>
using namespace boost::parameter;
BOOST_PARAMETER_NAME(arg1)
BOOST_PARAMETER_NAME(arg2)
struct callable2
{
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
(void), call, tag, (required (arg1,(int))(arg2,(int))))
{
std::cout << arg1 << ", " << arg2 << std::endl;
}
};

View File

@@ -1,16 +0,0 @@
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME(arg1)
BOOST_PARAMETER_NAME(arg2)
using namespace boost::parameter;
struct callable2
{
BOOST_PARAMETER_CONST_MEMBER_FUNCTION(
(void), call, tag, (required (arg1,(int))(arg2,(int))))
{
call_impl(arg1,arg2);
}
private:
void call_impl(int, int); // implemented elsewhere.
};

View File

@@ -1,103 +0,0 @@
#include <boost/parameter.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
BOOST_PARAMETER_NAME((_graph, graphs) graph)
BOOST_PARAMETER_NAME((_visitor, graphs) visitor)
BOOST_PARAMETER_NAME((_root_vertex, graphs) root_vertex)
BOOST_PARAMETER_NAME((_index_map, graphs) index_map)
BOOST_PARAMETER_NAME((_color_map, graphs) color_map)
using boost::mpl::_;
// We first need to define a few metafunction that we use in the
// predicates below.
template <class G>
struct traversal_category
{
typedef typename boost::graph_traits<G>::traversal_category type;
};
template <class G>
struct vertex_descriptor
{
typedef typename boost::graph_traits<G>::vertex_descriptor type;
};
template <class G>
struct value_type
{
typedef typename boost::property_traits<G>::value_type type;
};
template <class G>
struct key_type
{
typedef typename boost::property_traits<G>::key_type type;
};
template<class Size, class IndexMap>
boost::iterator_property_map<
boost::default_color_type*, IndexMap
, boost::default_color_type, boost::default_color_type&
>
default_color_map(Size num_vertices, IndexMap const& index_map)
{
std::vector<boost::default_color_type> colors(num_vertices);
return &colors[0];
}
BOOST_PARAMETER_FUNCTION(
(void), depth_first_search, graphs
, (required
(graph
, *(boost::mpl::and_<
boost::is_convertible<
traversal_category<_>, boost::incidence_graph_tag
>
, boost::is_convertible<
traversal_category<_>, boost::vertex_list_graph_tag
>
>) ))
(optional
(visitor, *, boost::dfs_visitor<>()) // not checkable
(root_vertex
, (vertex_descriptor<graphs::graph::_>)
, *vertices(graph).first)
(index_map
, *(boost::mpl::and_<
boost::is_integral<value_type<_> >
, boost::is_same<
vertex_descriptor<graphs::graph::_>, key_type<_>
>
>)
, get(boost::vertex_index,graph))
(in_out(color_map)
, *(boost::is_same<
vertex_descriptor<graphs::graph::_>, key_type<_>
>)
, default_color_map(num_vertices(graph), index_map) )
)
)
{}
int main()
{
typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::directedS> G;
enum {u, v, w, x, y, z, N};
typedef std::pair<int, int> E;
E edges[] = {E(u, v), E(u, x), E(x, v), E(y, x), E(v, y), E(w, y),
E(w,z), E(z, z)};
G g(edges, edges + sizeof(edges) / sizeof(E), N);
::depth_first_search(g);
::depth_first_search(g, _root_vertex = (int)x);
}

View File

@@ -1,9 +0,0 @@
#include <boost/parameter.hpp>
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_FUNCTION((void), f, tag,
(required (graph, *) )
) {}

View File

@@ -1,14 +0,0 @@
#include <boost/parameter.hpp>
#include <iostream>
using namespace boost::parameter;
BOOST_PARAMETER_NAME(arg1)
struct somebody
{
BOOST_PARAMETER_MEMBER_FUNCTION(
(void), static f, tag, (optional (arg1,(int),0)))
{
std::cout << arg1 << std::endl;
}
};

View File

@@ -1,10 +0,0 @@
#include <boost/parameter.hpp>
namespace boost { namespace python {
BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list)
BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type)
BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable)
}}

View File

@@ -1,11 +0,0 @@
#include <boost/parameter.hpp>
namespace boost { namespace python {
namespace tag { struct class_type; } // keyword tag type
template <class T>
struct class_type
: parameter::template_keyword<tag::class_type,T>
{};
}}

View File

@@ -1,38 +0,0 @@
#include <boost/parameter.hpp>
namespace test
{
BOOST_PARAMETER_NAME(title)
BOOST_PARAMETER_NAME(width)
BOOST_PARAMETER_NAME(titlebar)
BOOST_PARAMETER_FUNCTION(
(int), new_window, tag, (required (title,*)(width,*)(titlebar,*)))
{
return 0;
}
BOOST_PARAMETER_TEMPLATE_KEYWORD(deleter)
BOOST_PARAMETER_TEMPLATE_KEYWORD(copy_policy)
template <class T> struct Deallocate {};
struct DeepCopy {};
namespace parameter = boost::parameter;
struct Foo {};
template <class T, class A0, class A1>
struct smart_ptr
{
smart_ptr(Foo*);
};
}
using namespace test;
int x =
new_window("alert", _width=10, _titlebar=false);
smart_ptr<
Foo
, deleter<Deallocate<Foo> >
, copy_policy<DeepCopy> > p(new Foo);

View File

@@ -1,43 +0,0 @@
#include <boost/parameter/name.hpp>
BOOST_PARAMETER_NAME(graph)
BOOST_PARAMETER_NAME(visitor)
BOOST_PARAMETER_NAME(root_vertex)
BOOST_PARAMETER_NAME(index_map)
BOOST_PARAMETER_NAME(color_map)
namespace boost {
template <class T = int>
struct dfs_visitor
{};
int vertex_index = 0;
}
#include <boost/parameter/preprocessor.hpp>
namespace graphs
{
BOOST_PARAMETER_FUNCTION(
(void), // 1. parenthesized return type
depth_first_search, // 2. name of the function template
tag, // 3. namespace of tag types
(required (graph, *) ) // 4. one required parameter, and
(optional // four optional parameters, with defaults
(visitor, *, boost::dfs_visitor<>())
(root_vertex, *, *vertices(graph).first)
(index_map, *, get(boost::vertex_index,graph))
(in_out(color_map), *,
default_color_map(num_vertices(graph), index_map) )
)
)
{
// ... body of function goes here...
// use graph, visitor, index_map, and color_map
}
}

View File

@@ -1,57 +0,0 @@
// Copyright David Abrahams, Daniel Wallin 2003. 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)
#include <boost/parameter.hpp>
#include <boost/parameter/macros.hpp>
#include <boost/bind.hpp>
#include <boost/static_assert.hpp>
#include <boost/ref.hpp>
#include <cassert>
#include <string.h>
#include "basics.hpp"
namespace test
{
BOOST_PARAMETER_FUN(int, f, 2, 4, f_parameters)
{
p[tester](
p[name]
, p[value || boost::bind(&value_default) ]
#if BOOST_WORKAROUND(__DECCXX_VER, BOOST_TESTED_AT(60590042))
, p[test::index | 999 ]
#else
, p[index | 999 ]
#endif
);
return 1;
}
} // namespace test
int main()
{
using test::f;
using test::name;
using test::value;
using test::index;
using test::tester;
f(
test::values(S("foo"), S("bar"), S("baz"))
, S("foo"), S("bar"), S("baz")
);
int x = 56;
f(
test::values("foo", 666.222, 56)
, index = boost::ref(x), name = "foo"
);
return boost::report_errors();
}

View File

@@ -1,35 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <boost/parameter/keyword.hpp>
#include <boost/parameter/aux_/maybe.hpp>
#include <cassert>
namespace test {
BOOST_PARAMETER_KEYWORD(tag, kw)
BOOST_PARAMETER_KEYWORD(tag, unused)
template <class Args>
int f(Args const& args)
{
return args[kw | 1.f];
}
} // namespace test
int main()
{
using test::kw;
using test::unused;
using test::f;
using boost::parameter::aux::maybe;
assert(f((kw = 0, unused = 0)) == 0);
assert(f(unused = 0) == 1);
assert(f((kw = maybe<int>(), unused = 0)) == 1);
assert(f((kw = maybe<int>(2), unused = 0)) == 2);
return 0;
}

View File

@@ -1,80 +0,0 @@
// Copyright David Abrahams 2006. 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 "basics.hpp"
#include <boost/mpl/list.hpp>
#include <boost/mpl/for_each.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/mpl/size.hpp>
#include <boost/type_traits/add_pointer.hpp>
# include <boost/mpl/contains.hpp>
namespace test
{
namespace mpl = boost::mpl;
template <class Set>
struct assert_in_set
{
template <class T>
void operator()(T*)
{
BOOST_MPL_ASSERT((mpl::contains<Set,T>));
}
};
template<class Expected, class Params>
void f_impl(Params const& p BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected))
{
BOOST_MPL_ASSERT_RELATION(
mpl::size<Expected>::value
, ==
, mpl::size<Params>::value
);
mpl::for_each<Params, boost::add_pointer<mpl::_1> >(assert_in_set<Expected>());
}
template<class Expected, class Tester, class Name, class Value, class Index>
void f(Tester const& t, const Name& name_,
const Value& value_, const Index& index_ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected))
{
f_impl<Expected>(f_parameters()(t, name_, value_, index_));
}
template<class Expected, class Tester, class Name, class Value>
void f(Tester const& t, const Name& name_, const Value& value_ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected))
{
f_impl<Expected>(f_parameters()(t, name_, value_));
}
template<class Expected, class Tester, class Name>
void f(Tester const& t, const Name& name_ BOOST_APPEND_EXPLICIT_TEMPLATE_TYPE(Expected))
{
f_impl<Expected>(f_parameters()(t, name_));
}
void run()
{
typedef test::tag::tester tester_;
typedef test::tag::name name_;
typedef test::tag::value value_;
typedef test::tag::index index_;
f<mpl::list4<tester_,name_,value_,index_> >(1, 2, 3, 4);
f<mpl::list3<tester_,name_,index_> >(1, 2, index = 3);
f<mpl::list3<tester_,name_,index_> >(1, index = 2, name = 3);
f<mpl::list2<name_,value_> >(name = 3, value = 4);
f_impl<mpl::list1<value_> >(value = 4);
}
}
int main()
{
test::run();
return 0;
}

View File

@@ -1,85 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <boost/parameter.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <cassert>
struct count_instances
{
count_instances()
{
++count;
}
count_instances(count_instances const&)
{
++count;
}
template <class T>
count_instances(T const&)
{
++count;
}
~count_instances()
{
--count;
}
static std::size_t count;
};
std::size_t count_instances::count = 0;
BOOST_PARAMETER_NAME(x)
BOOST_PARAMETER_NAME(y)
BOOST_PARAMETER_FUNCTION((int), f, tag,
(required
(x, (int))
(y, (int))
)
)
{
BOOST_MPL_ASSERT((boost::is_same<x_type,int>));
BOOST_MPL_ASSERT((boost::is_same<y_type,int>));
return 0;
}
BOOST_PARAMETER_FUNCTION((int), g, tag,
(required
(x, (count_instances))
)
)
{
BOOST_MPL_ASSERT((boost::is_same<x_type,count_instances>));
assert(count_instances::count > 0);
return 0;
}
BOOST_PARAMETER_FUNCTION((int), h, tag,
(required
(x, (count_instances const&))
)
)
{
BOOST_MPL_ASSERT((boost::is_same<x_type,count_instances const>));
assert(count_instances::count == 1);
return 0;
}
int main()
{
f(1, 2);
f(1., 2.f);
f(1U, 2L);
g(0);
h(0);
}

View File

@@ -1,110 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <boost/parameter.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_base_and_derived.hpp>
namespace mpl = boost::mpl;
namespace parameter = boost::parameter;
template <class T = int>
struct a0_is
: parameter::template_keyword<a0_is<>, T>
{};
template <class T = int>
struct a1_is
: parameter::template_keyword<a1_is<>, T>
{};
template <class T = int>
struct a2_is
: parameter::template_keyword<a2_is<>, T>
{};
template <class T = int>
struct a3_is
: parameter::template_keyword<a3_is<>, T>
{};
struct X {};
struct Y : X {};
template <
class A0 = parameter::void_
, class A1 = parameter::void_
, class A2 = parameter::void_
, class A3 = parameter::void_
>
struct with_ntp
{
typedef typename parameter::parameters<
a0_is<>, a1_is<>, a2_is<>
, parameter::optional<
parameter::deduced<a3_is<> >
, boost::is_base_and_derived<X, mpl::_>
>
>::bind<A0,A1,A2,A3
#if BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
, parameter::void_
#endif
>::type args;
typedef typename parameter::binding<
args, a0_is<>, void*
>::type a0;
typedef typename parameter::binding<
args, a1_is<>, void*
>::type a1;
typedef typename parameter::binding<
args, a2_is<>, void*
>::type a2;
typedef typename parameter::binding<
args, a3_is<>, void*
>::type a3;
typedef void(*type)(a0,a1,a2,a3);
};
BOOST_MPL_ASSERT((boost::is_same<
with_ntp<>::type, void(*)(void*,void*,void*,void*)
>));
BOOST_MPL_ASSERT((boost::is_same<
with_ntp<a2_is<int> >::type, void(*)(void*,void*,int,void*)
>));
BOOST_MPL_ASSERT((boost::is_same<
with_ntp<a1_is<int> >::type, void(*)(void*,int,void*,void*)
>));
BOOST_MPL_ASSERT((boost::is_same<
with_ntp<a2_is<int const>, a1_is<float> >::type, void(*)(void*,float,int const,void*)
>));
BOOST_MPL_ASSERT((boost::is_same<
with_ntp<int const>::type, void(*)(int const, void*, void*,void*)
>));
BOOST_MPL_ASSERT((boost::is_same<
with_ntp<int, float>::type, void(*)(int, float, void*,void*)
>));
BOOST_MPL_ASSERT((boost::is_same<
with_ntp<int, float, char>::type, void(*)(int, float, char,void*)
>));
BOOST_MPL_ASSERT((boost::is_same<
with_ntp<a0_is<int>, Y>::type, void(*)(int,void*,void*, Y)
>));
BOOST_MPL_ASSERT((boost::is_same<
with_ntp<int&, a2_is<char>, Y>::type, void(*)(int&,void*,char, Y)
>));

View File

@@ -1,73 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <boost/parameter/preprocessor.hpp>
#include <boost/parameter/name.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/tuple/tuple.hpp>
#include <string>
#include "basics.hpp"
#include <boost/utility/enable_if.hpp>
namespace test {
namespace mpl = boost::mpl;
using mpl::_;
using boost::is_convertible;
BOOST_PARAMETER_NAME(x)
// Sun has problems with this syntax:
//
// template1< r* ( template2<x> ) >
//
// Workaround: factor template2<x> into a separate typedef
#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
typedef is_convertible<_,char const*> predicate;
BOOST_PARAMETER_FUNCTION((int), sfinae, tag,
(deduced
(optional (x, *(predicate), 0))
)
)
{
return 1;
}
#else
BOOST_PARAMETER_FUNCTION((int), sfinae, tag,
(deduced
(optional (x, *(is_convertible<_,char const*>), 0))
)
)
{
return 1;
}
#endif
template<class A0>
typename boost::enable_if<boost::is_same<int,A0>, int>::type
sfinae(A0 const& a0)
{
return 0;
}
} // namespace test
int main()
{
using namespace test;
assert(sfinae() == 1);
assert(sfinae("foo") == 1);
assert(sfinae(1) == 0);
return 0;
}

View File

@@ -1,482 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <boost/parameter/preprocessor.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/type_traits/is_const.hpp>
#include <string>
#include "basics.hpp"
#ifndef BOOST_NO_SFINAE
# include <boost/utility/enable_if.hpp>
#endif
namespace test {
BOOST_PARAMETER_BASIC_FUNCTION((int), f, tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *)
(out(index), (int))
)
)
{
typedef typename boost::parameter::binding<
Args, tag::index, int&
>::type index_type;
BOOST_MPL_ASSERT((boost::is_same<index_type, int&>));
args[tester](
args[name]
, args[value | 1.f]
, args[index | 2]
);
return 1;
}
BOOST_PARAMETER_BASIC_FUNCTION((int), g, tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *)
(out(index), (int))
)
)
{
typedef typename boost::parameter::binding<
Args, tag::index, int const&
>::type index_type;
BOOST_MPL_ASSERT((boost::is_same<index_type, int const&>));
args[tester](
args[name]
, args[value | 1.f]
, args[index | 2]
);
return 1;
}
BOOST_PARAMETER_FUNCTION((int), h, tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *, 1.f)
(out(index), (int), 2)
)
)
{
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
&& !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
BOOST_MPL_ASSERT((boost::is_same<index_type, int>));
# endif
tester(
name
, value
, index
);
return 1;
}
BOOST_PARAMETER_FUNCTION((int), h2, tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *, 1.f)
(out(index), (int), (int)value * 2)
)
)
{
# if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) \
&& !BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
BOOST_MPL_ASSERT((boost::is_same<index_type, int>));
# endif
tester(
name
, value
, index
);
return 1;
}
struct base
{
template <class Args>
base(Args const& args)
{
args[tester](
args[name]
, args[value | 1.f]
, args[index | 2]
);
}
};
struct class_ : base
{
BOOST_PARAMETER_CONSTRUCTOR(class_, (base), tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *)
(index, *)
)
)
BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((int), f, tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *)
(index, *)
)
)
{
args[tester](
args[name]
, args[value | 1.f]
, args[index | 2]
);
return 1;
}
BOOST_PARAMETER_BASIC_CONST_MEMBER_FUNCTION((int), f, tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *)
(index, *)
)
)
{
args[tester](
args[name]
, args[value | 1.f]
, args[index | 2]
);
return 1;
}
BOOST_PARAMETER_MEMBER_FUNCTION((int), f2, tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *, 1.f)
(index, *, 2)
)
)
{
tester(name, value, index);
return 1;
}
BOOST_PARAMETER_CONST_MEMBER_FUNCTION((int), f2, tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *, 1.f)
(index, *, 2)
)
)
{
tester(name, value, index);
return 1;
}
BOOST_PARAMETER_MEMBER_FUNCTION((int), static f_static, tag,
(required
(tester, *)
(name, *)
)
(optional
(value, *, 1.f)
(index, *, 2)
)
)
{
tester(name, value, index);
return 1;
}
};
BOOST_PARAMETER_FUNCTION(
(int), sfinae, tag,
(required
(name, (std::string))
)
)
{
return 1;
}
#ifndef BOOST_NO_SFINAE
// On compilers that actually support SFINAE, add another overload
// that is an equally good match and can only be in the overload set
// when the others are not. This tests that the SFINAE is actually
// working. On all other compilers we're just checking that
// everything about SFINAE-enabled code will work, except of course
// the SFINAE.
template<class A0>
typename boost::enable_if<boost::is_same<int,A0>, int>::type
sfinae(A0 const& a0)
{
return 0;
}
#endif
#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
// Sun has problems with this syntax:
//
// template1< r* ( template2<x> ) >
//
// Workaround: factor template2<x> into a separate typedef
typedef boost::is_convertible<boost::mpl::_, std::string> predicate;
BOOST_PARAMETER_FUNCTION(
(int), sfinae1, tag,
(required
(name, *(predicate))
)
)
{
return 1;
}
#else
BOOST_PARAMETER_FUNCTION(
(int), sfinae1, tag,
(required
(name, *(boost::is_convertible<boost::mpl::_, std::string>))
)
)
{
return 1;
}
#endif
#ifndef BOOST_NO_SFINAE
// On compilers that actually support SFINAE, add another overload
// that is an equally good match and can only be in the overload set
// when the others are not. This tests that the SFINAE is actually
// working. On all other compilers we're just checking that
// everything about SFINAE-enabled code will work, except of course
// the SFINAE.
template<class A0>
typename boost::enable_if<boost::is_same<int,A0>, int>::type
sfinae1(A0 const& a0)
{
return 0;
}
#endif
template <class T>
T const& as_lvalue(T const& x)
{
return x;
}
struct udt
{
udt(int foo, int bar)
: foo(foo)
, bar(bar)
{}
int foo;
int bar;
};
BOOST_PARAMETER_FUNCTION((int), lazy_defaults, tag,
(required
(name, *)
)
(optional
(value, *, name.foo)
(index, *, name.bar)
)
)
{
return 0;
}
} // namespace test
int main()
{
using namespace test;
f(
values(S("foo"), 1.f, 2)
, S("foo")
);
f(
tester = values(S("foo"), 1.f, 2)
, name = S("foo")
);
int index_lvalue = 2;
f(
tester = values(S("foo"), 1.f, 2)
, name = S("foo")
, value = 1.f
, test::index = index_lvalue
);
f(
values(S("foo"), 1.f, 2)
, S("foo")
, 1.f
, index_lvalue
);
g(
values(S("foo"), 1.f, 2)
, S("foo")
, 1.f
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
, as_lvalue(2)
#else
, 2
#endif
);
h(
values(S("foo"), 1.f, 2)
, S("foo")
, 1.f
#if BOOST_WORKAROUND(BOOST_MSVC, == 1300)
, as_lvalue(2)
#else
, 2
#endif
);
h2(
tester = values(S("foo"), 1.f, 2)
, name = S("foo")
, value = 1.f
);
class_ x(
values(S("foo"), 1.f, 2)
, S("foo"), test::index = 2
);
x.f(
values(S("foo"), 1.f, 2)
, S("foo")
);
x.f(
tester = values(S("foo"), 1.f, 2)
, name = S("foo")
);
x.f2(
values(S("foo"), 1.f, 2)
, S("foo")
);
x.f2(
tester = values(S("foo"), 1.f, 2)
, name = S("foo")
);
class_ const& x_const = x;
x_const.f(
values(S("foo"), 1.f, 2)
, S("foo")
);
x_const.f(
tester = values(S("foo"), 1.f, 2)
, name = S("foo")
);
x_const.f2(
values(S("foo"), 1.f, 2)
, S("foo")
);
x_const.f2(
tester = values(S("foo"), 1.f, 2)
, name = S("foo")
);
x_const.f2(
tester = values(S("foo"), 1.f, 2)
, name = S("foo")
);
class_::f_static(
values(S("foo"), 1.f, 2)
, S("foo")
);
class_::f_static(
tester = values(S("foo"), 1.f, 2)
, name = S("foo")
);
#if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
assert(sfinae("foo") == 1);
assert(sfinae(1) == 0);
# if !BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
// Sun actually eliminates the desired overload for some reason.
// Disabling this part of the test because SFINAE abilities are
// not the point of this test.
assert(sfinae1("foo") == 1);
# endif
assert(sfinae1(1) == 0);
#endif
lazy_defaults(
name = udt(0,1)
);
lazy_defaults(
name = 0
, value = 1
, test::index = 2
);
return boost::report_errors();
}

View File

@@ -1,171 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <boost/parameter/preprocessor.hpp>
#include <boost/parameter/name.hpp>
#include <boost/type_traits/is_convertible.hpp>
#include <boost/tuple/tuple.hpp>
#include <string>
#include "basics.hpp"
#ifndef BOOST_NO_SFINAE
# include <boost/utility/enable_if.hpp>
#endif
namespace test {
namespace mpl = boost::mpl;
using mpl::_;
using boost::is_convertible;
BOOST_PARAMETER_NAME(expected)
BOOST_PARAMETER_NAME(x)
BOOST_PARAMETER_NAME(y)
BOOST_PARAMETER_NAME(z)
// Sun has problems with this syntax:
//
// template1< r* ( template2<x> ) >
//
// Workaround: factor template2<x> into a separate typedef
typedef is_convertible<_, int> predicate1;
typedef is_convertible<_, std::string> predicate2;
#if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580))
BOOST_PARAMETER_FUNCTION((int), f, tag,
(required
(expected, *)
)
(deduced
(required
(x, *(predicate1))
(y, *(predicate2))
)
)
)
#else
BOOST_PARAMETER_FUNCTION((int), f, tag,
(required
(expected, *)
)
(deduced
(required
(x, *(is_convertible<_, int>))
(y, *(is_convertible<_, std::string>))
)
)
)
#endif
{
assert(equal(x, boost::tuples::get<0>(expected)));
assert(equal(y, boost::tuples::get<1>(expected)));
return 1;
}
struct X
{
X(int x = -1)
: x(x)
{}
bool operator==(X const& other) const
{
return x == other.x;
}
int x;
};
typedef is_convertible<_, X> predicate3; // SunPro workaround; see above
BOOST_PARAMETER_FUNCTION((int), g, tag,
(required
(expected, *)
)
(deduced
(required
(x, *(is_convertible<_, int>))
(y, *(is_convertible<_, std::string>))
)
(optional
(z, *(predicate3), X())
)
)
)
{
assert(equal(x, boost::tuples::get<0>(expected)));
assert(equal(y, boost::tuples::get<1>(expected)));
assert(equal(z, boost::tuples::get<2>(expected)));
return 1;
}
BOOST_PARAMETER_FUNCTION(
(int), sfinae, tag,
(deduced
(required
(x, *(predicate2))
)
)
)
{
return 1;
}
#ifndef BOOST_NO_SFINAE
// On compilers that actually support SFINAE, add another overload
// that is an equally good match and can only be in the overload set
// when the others are not. This tests that the SFINAE is actually
// working. On all other compilers we're just checking that
// everything about SFINAE-enabled code will work, except of course
// the SFINAE.
template<class A0>
typename boost::enable_if<boost::is_same<int,A0>, int>::type
sfinae(A0 const& a0)
{
return 0;
}
#endif
} // namespace test
using boost::make_tuple;
// make_tuple doesn't work with char arrays.
char const* str(char const* s)
{
return s;
}
int main()
{
using namespace test;
f(make_tuple(0, str("foo")), _x = 0, _y = "foo");
f(make_tuple(0, str("foo")), _x = 0, _y = "foo");
f(make_tuple(0, str("foo")), 0, "foo");
f(make_tuple(0, str("foo")), "foo", 0);
f(make_tuple(0, str("foo")), _y = "foo", 0);
f(make_tuple(0, str("foo")), _x = 0, "foo");
f(make_tuple(0, str("foo")), 0, _y = "foo");
g(make_tuple(0, str("foo"), X()), _x = 0, _y = "foo");
g(make_tuple(0, str("foo"), X()), 0, "foo");
g(make_tuple(0, str("foo"), X()), "foo", 0);
g(make_tuple(0, str("foo"), X()), _y = "foo", 0);
g(make_tuple(0, str("foo"), X()), _x = 0, "foo");
g(make_tuple(0, str("foo"), X()), 0, _y = "foo");
g(make_tuple(0, str("foo"), X(1)), 0, _y = "foo", X(1));
g(make_tuple(0, str("foo"), X(1)), X(1), 0, _y = "foo");
#ifndef BOOST_NO_SFINAE
assert(sfinae("foo") == 1);
assert(sfinae(0) == 0);
#endif
return 0;
}

View File

@@ -1,172 +0,0 @@
// Copyright Daniel Wallin 2006. 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)
#include <math.h>
#include <boost/python.hpp>
#include <boost/parameter/preprocessor.hpp>
#include <boost/parameter/keyword.hpp>
#include <boost/parameter/python.hpp>
#include <boost/utility/enable_if.hpp>
namespace test {
BOOST_PARAMETER_KEYWORD(tags, x)
BOOST_PARAMETER_KEYWORD(tags, y)
BOOST_PARAMETER_KEYWORD(tags, z)
struct Xbase
{
// We need the disable_if part for VC7.1/8.0.
template <class Args>
Xbase(
Args const& args
, typename boost::disable_if<
boost::is_base_and_derived<Xbase, Args>
>::type* = 0
)
: value(std::string(args[x | "foo"]) + args[y | "bar"])
{}
std::string value;
};
struct X : Xbase
{
BOOST_PARAMETER_CONSTRUCTOR(X, (Xbase), tags,
(optional
(x, *)
(y, *)
)
)
BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((int), f, tags,
(required
(x, *)
(y, *)
)
(optional
(z, *)
)
)
{
return args[x] + args[y] + args[z | 0];
}
BOOST_PARAMETER_BASIC_MEMBER_FUNCTION((std::string), g, tags,
(optional
(x, *)
(y, *)
)
)
{
return std::string(args[x | "foo"]) + args[y | "bar"];
}
BOOST_PARAMETER_MEMBER_FUNCTION((X&), h, tags,
(optional (x, *, "") (y, *, ""))
)
{
return *this;
}
template <class A0>
X& operator()(A0 const& a0)
{
return *this;
}
};
} // namespace test
struct f_fwd
{
template <class R, class T, class A0, class A1, class A2>
R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1, A2 const& a2)
{
return self.f(a0,a1,a2);
}
};
struct g_fwd
{
template <class R, class T, class A0, class A1>
R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1)
{
return self.g(a0,a1);
}
};
struct h_fwd
{
template <class R, class T>
R operator()(boost::type<R>, T& self)
{
return self.h();
}
template <class R, class T, class A0>
R operator()(boost::type<R>, T& self, A0 const& a0)
{
return self.h(a0);
}
template <class R, class T, class A0, class A1>
R operator()(boost::type<R>, T& self, A0 const& a0, A1 const& a1)
{
return self.h(a0,a1);
}
};
BOOST_PYTHON_MODULE(python_test_ext)
{
namespace mpl = boost::mpl;
using namespace test;
using namespace boost::python;
class_<X>("X")
.def(
boost::parameter::python::init<
mpl::vector<
tags::x*(std::string), tags::y*(std::string)
>
>()
)
.def(
"f"
, boost::parameter::python::function<
f_fwd
, mpl::vector<
int, tags::x(int), tags::y(int), tags::z*(int)
>
>()
)
.def(
"g"
, boost::parameter::python::function<
g_fwd
, mpl::vector<
std::string, tags::x*(std::string), tags::y*(std::string)
>
>()
)
.def(
"h"
, boost::parameter::python::function<
h_fwd
, mpl::vector<
X&, tags::x**(std::string), tags::y**(std::string)
>
>()
, return_arg<>()
)
.def(
boost::parameter::python::call<
mpl::vector<
X&, tags::x(int)
>
>() [ return_arg<>() ]
)
.def_readonly("value", &X::value);
}

View File

@@ -1,41 +0,0 @@
# Copyright Daniel Wallin 2006. 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)
'''
>>> from python_test_ext import X
>>> x = X(y = 'baz')
>>> x.value
'foobaz'
>>> x.f(1,2)
3
>>> x.f(1,2,3)
6
>>> x.f(1,2, z = 3)
6
>>> x.f(z = 3, y = 2, x = 1)
6
>>> x.g()
'foobar'
>>> x.g(y = "baz")
'foobaz'
>>> x.g(x = "baz")
'bazbar'
>>> x.g(y = "foo", x = "bar")
'barfoo'
>>> y = x.h(x = "bar", y = "foo")
>>> assert x == y
>>> y = x(0)
>>> assert x == y
'''
def run(args = None):
if args is not None:
import sys
sys.argv = args
import doctest, python_test
return doctest.testmod(python_test)
if __name__ == '__main__':
import sys
sys.exit(run()[0])

View File

@@ -1,104 +0,0 @@
// Copyright David Abrahams, Daniel Wallin 2003. 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
#include <boost/parameter.hpp>
#include <boost/parameter/match.hpp>
#include <boost/detail/lightweight_test.hpp>
#include <string>
#include <boost/type_traits/is_convertible.hpp>
#if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
# include <boost/utility/enable_if.hpp>
# include <boost/type_traits/is_same.hpp>
#endif
namespace test
{
BOOST_PARAMETER_KEYWORD(keywords,name)
BOOST_PARAMETER_KEYWORD(keywords,value)
using namespace boost::parameter;
struct f_parameters
: parameters<
optional<
keywords::name
, boost::is_convertible<boost::mpl::_, std::string>
>
, optional<
keywords::value
, boost::is_convertible<boost::mpl::_, float>
>
>
{};
// The use of assert_equal_string is just a nasty workaround for a
// vc++ 6 ICE.
void assert_equal_string(std::string x, std::string y)
{
BOOST_TEST(x == y);
}
template<class P>
void f_impl(P const& p)
{
float v = p[value | 3.f];
BOOST_TEST(v == 3.f);
assert_equal_string(p[name | "bar"], "foo");
}
void f()
{
f_impl(f_parameters()());
}
template<class A0>
void f(
A0 const& a0
, BOOST_PARAMETER_MATCH(f_parameters, (A0), args))
{
f_impl(args(a0));
}
template<class A0, class A1>
void f(
A0 const& a0, A1 const& a1
, BOOST_PARAMETER_MATCH(f_parameters,(A0)(A1), args))
{
f_impl(args(a0, a1));
}
#if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
// On compilers that actually support SFINAE, add another overload
// that is an equally good match and can only be in the overload set
// when the others are not. This tests that the SFINAE is actually
// working. On all other compilers we're just checking that
// everything about SFINAE-enabled code will work, except of course
// the SFINAE.
template<class A0, class A1>
typename boost::enable_if<boost::is_same<int,A0>, int>::type
f(A0 const& a0, A1 const& a1)
{
return 0;
}
#endif
} // namespace test
int main()
{
using test::name;
using test::value;
using test::f;
f("foo");
f("foo", 3.f);
f(value = 3.f, name = "foo");
#if ! defined(BOOST_NO_SFINAE) && ! BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x592))
BOOST_TEST(f(3, 4) == 0);
#endif
return boost::report_errors();
}

View File

@@ -1,42 +0,0 @@
// Copyright Daniel Wallin 2005. 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)
#include <boost/parameter/keyword.hpp>
#include <boost/detail/lightweight_test.hpp>
BOOST_PARAMETER_KEYWORD(tag, x)
BOOST_PARAMETER_KEYWORD(tag, y)
struct default_src
{
typedef int result_type;
int operator()() const
{
return 0;
}
};
template <class ArgumentPack, class K, class T>
void check(ArgumentPack const& p, K const& kw, T const& value)
{
BOOST_TEST(p[kw] == value);
}
int main()
{
check(x = 20, x, 20);
check(y = 20, y, 20);
check(x = 20, x | 0, 20);
check(y = 20, y | 0, 20);
check(x = 20, x | default_src(), 20);
check(y = 20, y | default_src(), 20);
check(y = 20, x | 0, 0);
check(y = 20, x || default_src(), 0);
return boost::report_errors();
}

View File

@@ -1,128 +0,0 @@
# Copyright David Abrahams 2005. 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)
----------------- Test #1 ----------------
Testers:
Matthias Troyer, Michael Gauckler, David Abrahams
Date:
2005-09-09
Compiler:
Cygwin g++-4.0.0
Command lines:
g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops \
-O3 -finline-functions -Wno-inline -DNDEBUG efficiency.cpp
g++ -o efficiency.exe efficiency.o -Wl,--strip-all
efficiency && efficiency && efficiency
Machine:
Dell Inspiron 9300
Intel(R) Pentium(R) M processor 2.00GHz
Running on 230 volts AC power
Timings:
Run #1 results discarded per standard practice
Run #2
plain time: 0.75
named parameter time: 0.734
Run #3
plain time: 0.781
named parameter time: 0.766
----------------- Test #2 ----------------
Testers:
Chris Frey
Date:
2005-09-17
Compiler:
Linux kernel 2.4.27
gcc version 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)
Command lines:
g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops \
-O3 -finline-functions -Wno-inline -DNDEBUG efficiency.cpp
g++ -o efficiency.exe efficiency.o -Wl,--strip-all
Machine:
IBM Thinkpad 770Z, running on AC power
Intel Pentium II 366Mhz
Timings:
Run #1 results discarded per standard practice
Run #2
plain time: 6.42
named parameter time: 7.34
Run #3
plain time: 6.42
named parameter time: 7.34
----------------- Test #2 ----------------
Testers:
Stuar Dootson
Date:
2005-09-18
Machine:
Athlon 64 3500+ laptop, running on AC power
Windows XP SP2
Compiler: Visual C++ 7.1
command line:
cl -O2 efficiency.cpp -EHsc -I\lib\boost\include\boost-1_33
Results:
plain time: <ignored>
named parameter time: <ignored>
plain time: 1.453
named parameter time: 1.437
plain time: 1.453
named parameter time: 1.453
Compiler: Visual C++ 8.0
command-line:
cl -O2 efficiency.cpp -EHsc -I\lib\boost\include\boost-1_33
Results:
plain time: <ignored>
named parameter time: <ignored>
plain time: 1.438
named parameter time: 1.453
plain time: 1.438
named parameter time: 1.437
Compiler: Mingw gcc 3.4.2
command-line:
g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops -O3
-finline-functions -Wno-inline -DNDEBUG efficiency.cpp
-I\lib\boost\include\boost-1_33
g++ -o efficiency.exe efficiency.o -Wl,--strip-all
Results:
plain time: <ignored>
named parameter time: <ignored>
plain time: 1.14
named parameter time: 1.422
plain time: 1.125
named parameter time: 1.406
-----------------------------------------

View File

@@ -1,38 +0,0 @@
// Copyright David Abrahams 2005. 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 <iostream>
#include <boost/parameter/keyword.hpp>
namespace graphs
{
BOOST_PARAMETER_KEYWORD(tag, graph) // Note: no semicolon
BOOST_PARAMETER_KEYWORD(tag, visitor)
BOOST_PARAMETER_KEYWORD(tag, root_vertex)
BOOST_PARAMETER_KEYWORD(tag, index_map)
BOOST_PARAMETER_KEYWORD(tag, color_map)
}
namespace graphs { namespace core
{
template <class ArgumentPack>
void depth_first_search(ArgumentPack const& args)
{
std::cout << "graph:\t" << args[graph] << std::endl;
std::cout << "visitor:\t" << args[visitor] << std::endl;
std::cout << "root_vertex:\t" << args[root_vertex] << std::endl;
std::cout << "index_map:\t" << args[index_map] << std::endl;
std::cout << "color_map:\t" << args[color_map] << std::endl;
}
}} // graphs::core
int main()
{
using namespace graphs;
core::depth_first_search((
graph = 'G', visitor = 2, root_vertex = 3.5,
index_map = "hello, world", color_map = false));
return 0;
}

View File

@@ -1,30 +0,0 @@
// Copyright David Abrahams 2005. 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/parameter/aux_/unwrap_cv_reference.hpp>
#include <boost/mpl/assert.hpp>
#include <boost/ref.hpp>
#include <boost/type_traits/is_same.hpp>
namespace test
{
using namespace boost::parameter::aux;
using namespace boost;
struct foo {};
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<int>::type,int>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<int const>::type,int const>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<int volatile>::type,int volatile>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<int const volatile>::type,int const volatile>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<foo>::type,foo>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<foo const>::type,foo const>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<foo volatile>::type,foo volatile>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<foo const volatile>::type,foo const volatile>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<reference_wrapper<foo> >::type,foo>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<reference_wrapper<foo> const>::type,foo>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<reference_wrapper<foo> volatile>::type,foo>));
BOOST_MPL_ASSERT((is_same<unwrap_cv_reference<reference_wrapper<foo> const volatile>::type,foo>));
}