├── doc ├── html │ ├── vellipsis.gif │ └── rst.css └── Jamfile.v2 ├── test ├── literate │ ├── headers-and-namespaces0.cpp │ ├── README │ ├── required-parameters0.cpp │ ├── defining-the-keywords0.cpp │ ├── template-keywords0.cpp │ ├── class-template-skeleton0.cpp │ ├── template-keywords1.cpp │ ├── fine-grained-name-control0.cpp │ ├── parameter-enabled-member-functions1.cpp │ ├── extracting-parameter-types1.cpp │ ├── defining-the-keywords1.cpp │ ├── static-member-functions0.cpp │ ├── namespaces0.cpp │ ├── namespaces2.cpp │ ├── namespaces1.cpp │ ├── parameter-enabled-function-call-operators0.cpp │ ├── parameter-enabled-member-functions0.cpp │ ├── namespaces3.cpp │ ├── lazy-default-computation0.cpp │ ├── optional-parameters0.cpp │ ├── handling-out-parameters0.cpp │ ├── parameter-enabled-constructors0.cpp │ ├── lazy-default-computation1.cpp │ ├── default-expression-evaluation0.cpp │ ├── top-level0.cpp │ ├── extracting-parameter-types0.cpp │ ├── writing-the-function0.cpp │ ├── building-argumentpacks0.cpp │ └── deduced-parameters0.cpp ├── duplicates.cpp ├── deduced_unmatched_arg.cpp ├── maybe.cpp ├── tutorial.cpp ├── CMakeLists.txt ├── macros.cpp ├── timer.hpp ├── optional_deduced_sfinae.cpp ├── timings.txt ├── basics.cpp ├── earwicker.cpp ├── function_type_tpl_param.cpp ├── deduced.hpp ├── basics.hpp └── sfinae.cpp ├── config ├── Jamfile.v2 └── graph_supported.cpp ├── include └── boost │ ├── parameter │ ├── aux_ │ │ ├── cast.hpp │ │ ├── preprocessor │ │ │ ├── flatten.hpp │ │ │ ├── for_each.hpp │ │ │ ├── nullptr.hpp │ │ │ ├── seq_enum.hpp │ │ │ ├── no_perfect_forwarding_end.hpp │ │ │ ├── impl │ │ │ │ ├── argument_specs.hpp │ │ │ │ ├── function_dispatch_tuple.hpp │ │ │ │ ├── parenthesized_type.hpp │ │ │ │ ├── function_forward_match.hpp │ │ │ │ ├── arity_range.hpp │ │ │ │ ├── split_args.hpp │ │ │ │ └── parenthesized_return_type.hpp │ │ │ ├── is_binary.hpp │ │ │ ├── is_nullary.hpp │ │ │ ├── convert_binary_seq.hpp │ │ │ ├── binary_seq_to_args.hpp │ │ │ ├── inc_binary_seq.hpp │ │ │ ├── qualifier.hpp │ │ │ └── overloads.hpp │ │ ├── parameter_requirements.hpp │ │ ├── parenthesized_type.hpp │ │ ├── use_default.hpp │ │ ├── lambda_tag.hpp │ │ ├── as_lvalue.hpp │ │ ├── pack │ │ │ ├── insert_tagged.hpp │ │ │ ├── tag_keyword_arg.hpp │ │ │ ├── parameter_requirements.hpp │ │ │ ├── tag_template_keyword_arg.hpp │ │ │ ├── deduced_item.hpp │ │ │ ├── unmatched_argument.hpp │ │ │ ├── as_parameter_requirements.hpp │ │ │ ├── is_named_argument.hpp │ │ │ ├── item.hpp │ │ │ ├── make_items.hpp │ │ │ ├── make_deduced_items.hpp │ │ │ ├── tag_deduced.hpp │ │ │ ├── tag_keyword_arg_ref.hpp │ │ │ ├── tag_type.hpp │ │ │ └── predicate.hpp │ │ ├── use_default_tag.hpp │ │ ├── void.hpp │ │ ├── tagged_argument_fwd.hpp │ │ ├── always_true_predicate.hpp │ │ ├── is_maybe.hpp │ │ ├── yesno.hpp │ │ ├── result_of0.hpp │ │ ├── is_placeholder.hpp │ │ ├── pp_impl │ │ │ ├── match.hpp │ │ │ ├── unwrap_predicate.hpp │ │ │ └── argument_pack.hpp │ │ ├── template_keyword.hpp │ │ ├── name.hpp │ │ ├── is_tagged_argument.hpp │ │ ├── set.hpp │ │ ├── has_nested_template_fn.hpp │ │ ├── default.hpp │ │ └── maybe.hpp │ ├── keyword_fwd.hpp │ ├── is_argument_pack.hpp │ ├── match.hpp │ ├── required.hpp │ ├── optional.hpp │ ├── template_keyword.hpp │ ├── preprocessor_no_spec.hpp │ ├── config.hpp │ └── deduced.hpp │ └── parameter.hpp ├── index.html ├── meta └── libraries.json ├── CMakeLists.txt ├── README.md ├── appveyor.yml └── .gitattributes /doc/html/vellipsis.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/boostorg/parameter/HEAD/doc/html/vellipsis.gif -------------------------------------------------------------------------------- /test/literate/headers-and-namespaces0.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | using boost::parameter::keyword; 3 | 4 | -------------------------------------------------------------------------------- /test/literate/README: -------------------------------------------------------------------------------- 1 | These tests were extracted from the Boost.Parameter documentation 2 | with: 3 | 4 | python ../../../../tools/litre/tool.py \ 5 | ../../../../libs/parameter/doc/index.rst \ 6 | --dump_dir=. 7 | -------------------------------------------------------------------------------- /test/literate/required-parameters0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | BOOST_PARAMETER_NAME(graph) 5 | 6 | BOOST_PARAMETER_FUNCTION( 7 | (void), f, tag, (required (graph, *) ) 8 | ) 9 | { 10 | } 11 | 12 | -------------------------------------------------------------------------------- /config/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Copyright Andrey Semashev 2025. 2 | # 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # (See accompanying file LICENSE_1_0.txt or copy at 5 | # http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | exe graph_supported : graph_supported.cpp : /boost/graph//boost_graph ; 8 | explicit graph_supported ; 9 | -------------------------------------------------------------------------------- /test/literate/defining-the-keywords0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | namespace graphs { 5 | 6 | BOOST_PARAMETER_NAME(graph) // Note: no semicolon 7 | BOOST_PARAMETER_NAME(visitor) 8 | BOOST_PARAMETER_NAME(root_vertex) 9 | BOOST_PARAMETER_NAME(index_map) 10 | BOOST_PARAMETER_NAME(color_map) 11 | } 12 | -------------------------------------------------------------------------------- /test/literate/template-keywords0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | namespace boost { namespace python { 5 | 6 | BOOST_PARAMETER_TEMPLATE_KEYWORD(class_type) 7 | BOOST_PARAMETER_TEMPLATE_KEYWORD(base_list) 8 | BOOST_PARAMETER_TEMPLATE_KEYWORD(held_type) 9 | BOOST_PARAMETER_TEMPLATE_KEYWORD(copyable) 10 | }} 11 | 12 | -------------------------------------------------------------------------------- /test/literate/class-template-skeleton0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | namespace boost { namespace python { 5 | 6 | template < 7 | typename A0 8 | , typename A1 = boost::parameter::void_ 9 | , typename A2 = boost::parameter::void_ 10 | , typename A3 = boost::parameter::void_ 11 | > 12 | struct class_ 13 | { 14 | }; 15 | }} 16 | 17 | -------------------------------------------------------------------------------- /test/literate/template-keywords1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | namespace boost { namespace python { 5 | 6 | namespace tag { 7 | 8 | struct class_type; // keyword tag type 9 | } 10 | 11 | template 12 | struct class_type 13 | : boost::parameter::template_keyword 14 | { 15 | }; 16 | }} 17 | 18 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/cast.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_CAST_060902_HPP 7 | #define BOOST_PARAMETER_CAST_060902_HPP 8 | 9 | #include 10 | 11 | #endif // include guard 12 | 13 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/flatten.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_FLATTEN_051217_HPP 7 | #define BOOST_PARAMETER_FLATTEN_051217_HPP 8 | 9 | #include 10 | 11 | #endif // include guard 12 | 13 | -------------------------------------------------------------------------------- /test/literate/fine-grained-name-control0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | BOOST_PARAMETER_NAME((pass_foo, keywords) foo) 5 | 6 | BOOST_PARAMETER_FUNCTION( 7 | (int), f, keywords, (required (foo, *)) 8 | ) 9 | { 10 | return foo + 1; 11 | } 12 | 13 | #include 14 | 15 | int main() 16 | { 17 | int x = f(pass_foo = 41); 18 | BOOST_TEST_EQ(x, 42); 19 | return boost::report_errors(); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/for_each.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_FOR_EACH_051217_HPP 7 | #define BOOST_PARAMETER_FOR_EACH_051217_HPP 8 | 9 | #include 10 | 11 | #endif // include guard 12 | 13 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | Automatically loading index page... if nothing happens, please go to 10 | doc/html/index.html. 11 | 12 | 13 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/parameter_requirements.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin, David Abrahams 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PARAMETER_REQUIREMENTS_HPP 7 | #define BOOST_PARAMETER_AUX_PARAMETER_REQUIREMENTS_HPP 8 | 9 | #include 10 | 11 | #endif // include guard 12 | 13 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/parenthesized_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PARENTHESIZED_TYPE_DWA2006414_HPP 7 | #define BOOST_PARAMETER_AUX_PARENTHESIZED_TYPE_DWA2006414_HPP 8 | 9 | #include 10 | 11 | #endif // include guard 12 | 13 | -------------------------------------------------------------------------------- /test/literate/parameter-enabled-member-functions1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | BOOST_PARAMETER_NAME(arg1) 5 | BOOST_PARAMETER_NAME(arg2) 6 | 7 | using namespace boost::parameter; 8 | 9 | struct callable2 10 | { 11 | BOOST_PARAMETER_CONST_MEMBER_FUNCTION( 12 | (void), call, tag, (required (arg1,(int))(arg2,(int))) 13 | ) 14 | { 15 | call_impl(arg1, arg2); 16 | } 17 | 18 | private: 19 | void call_impl(int, int); // implemented elsewhere. 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /meta/libraries.json: -------------------------------------------------------------------------------- 1 | { 2 | "key": "parameter", 3 | "name": "Parameter", 4 | "authors": [ 5 | "David Abrahams", 6 | "Daniel Wallin" 7 | ], 8 | "description": "Boost.Parameter Library - Write functions that accept arguments by name.", 9 | "category": [ 10 | "Emulation", 11 | "Programming" 12 | ], 13 | "maintainers": [ 14 | "David Abrahams ", 15 | "Daniel Wallin " 16 | ], 17 | "cxxstd": "03" 18 | } 19 | -------------------------------------------------------------------------------- /test/literate/extracting-parameter-types1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | BOOST_PARAMETER_NAME(index) 5 | 6 | template 7 | typename boost::parameter::value_type::type 8 | twice_index(ArgumentPack const& args) 9 | { 10 | return 2 * args[_index|42]; 11 | } 12 | 13 | #include 14 | 15 | int main() 16 | { 17 | int six = twice_index(_index = 3); 18 | BOOST_TEST_EQ(six, 6); 19 | return boost::report_errors(); 20 | } 21 | 22 | -------------------------------------------------------------------------------- /test/literate/defining-the-keywords1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | namespace graphs { 5 | namespace tag { 6 | 7 | // keyword tag type 8 | struct graph 9 | { 10 | typedef boost::parameter::forward_reference qualifier; 11 | }; 12 | } 13 | 14 | namespace // unnamed 15 | { 16 | // A reference to the keyword object 17 | boost::parameter::keyword const& _graph 18 | = boost::parameter::keyword::instance; 19 | } 20 | } 21 | 22 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/use_default.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_USE_DEFAULT_HPP 7 | #define BOOST_PARAMETER_AUX_USE_DEFAULT_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | struct use_default 12 | { 13 | }; 14 | }}} // namespace boost::parameter::aux 15 | 16 | #endif // include guard 17 | 18 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/lambda_tag.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_LAMBDA_TAG_HPP 7 | #define BOOST_PARAMETER_AUX_LAMBDA_TAG_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | // Tag type passed to MPL lambda. 12 | struct lambda_tag; 13 | }}} // namespace boost::parameter::aux 14 | 15 | #endif // include guard 16 | 17 | -------------------------------------------------------------------------------- /test/literate/static-member-functions0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | using namespace boost::parameter; 6 | 7 | BOOST_PARAMETER_NAME(arg1) 8 | 9 | struct somebody 10 | { 11 | BOOST_PARAMETER_MEMBER_FUNCTION( 12 | (void), static f, tag, (optional (arg1,(int),0)) 13 | ) 14 | { 15 | std::cout << arg1 << std::endl; 16 | } 17 | }; 18 | 19 | #include 20 | 21 | int main() 22 | { 23 | somebody::f(); 24 | somebody::f(4); 25 | return boost::report_errors(); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/nullptr.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Cromwell D. Enage 2019. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_NULLPTR_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_NULLPTR_HPP 8 | 9 | #include 10 | 11 | #if defined(BOOST_NO_CXX11_NULLPTR) 12 | #define BOOST_PARAMETER_AUX_PP_NULLPTR 0 13 | #else 14 | #define BOOST_PARAMETER_AUX_PP_NULLPTR nullptr 15 | #endif 16 | 17 | #endif // include guard 18 | 19 | -------------------------------------------------------------------------------- /test/literate/namespaces0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | namespace lib { 6 | 7 | BOOST_PARAMETER_NAME(name) 8 | BOOST_PARAMETER_NAME(index) 9 | 10 | BOOST_PARAMETER_FUNCTION( 11 | (int), f, tag, (optional (name,*,"bob")(index,(int),1)) 12 | ) 13 | { 14 | std::cout << name << ":" << index << std::endl; 15 | return index; 16 | } 17 | } 18 | 19 | #include 20 | 21 | int main() 22 | { 23 | int x = lib::f(lib::_name = "jill", lib::_index = 1); 24 | BOOST_TEST_EQ(x, 1); 25 | return boost::report_errors(); 26 | } 27 | 28 | -------------------------------------------------------------------------------- /test/literate/namespaces2.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | namespace lib { 6 | 7 | BOOST_PARAMETER_NAME(name) 8 | BOOST_PARAMETER_NAME(index) 9 | 10 | BOOST_PARAMETER_FUNCTION( 11 | (int), f, tag, (optional (name,*,"bob")(index,(int),1)) 12 | ) 13 | { 14 | std::cout << name << ":" << index << std::endl; 15 | return index; 16 | } 17 | } 18 | 19 | #include 20 | 21 | using namespace lib; 22 | 23 | int main() 24 | { 25 | int x = f(_name = "jill", _index = 3); 26 | BOOST_TEST_EQ(x, 3); 27 | return boost::report_errors(); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/duplicates.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include "basics.hpp" 8 | 9 | namespace test { 10 | 11 | template 12 | void f(Params const &) 13 | { 14 | } 15 | } 16 | 17 | int main() 18 | { 19 | test::f(( 20 | test::_name = 1 21 | , test::_value = 1 22 | , test::_index = 1 23 | , test::_tester = 1 24 | , test::_value = 1 // repeated keyword: should not compile 25 | )); 26 | return 0; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /test/literate/namespaces1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | namespace lib { 6 | 7 | BOOST_PARAMETER_NAME(name) 8 | BOOST_PARAMETER_NAME(index) 9 | 10 | BOOST_PARAMETER_FUNCTION( 11 | (int), f, tag, (optional (name,*,"bob")(index,(int),1)) 12 | ) 13 | { 14 | std::cout << name << ":" << index << std::endl; 15 | return index; 16 | } 17 | } 18 | 19 | #include 20 | 21 | using lib::_name; 22 | using lib::_index; 23 | 24 | int main() 25 | { 26 | int x = lib::f(_name = "jill", _index = 1); 27 | BOOST_TEST_EQ(x, 1); 28 | return boost::report_errors(); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /config/graph_supported.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright Andrey Semashev 2025. 3 | * Distributed under the Boost Software License, Version 1.0. 4 | * (See accompanying file LICENSE_1_0.txt or copy at 5 | * http://www.boost.org/LICENSE_1_0.txt) 6 | */ 7 | 8 | // This test checks whether the portion of Boost.Graph that is used by Boost.Parameter tests 9 | // is compatible with the current compiler. The headers listed below are used in Boost.Parameter tests. 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | int main() 17 | { 18 | } 19 | -------------------------------------------------------------------------------- /test/literate/parameter-enabled-function-call-operators0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | using namespace boost::parameter; 6 | 7 | BOOST_PARAMETER_NAME(arg1) 8 | BOOST_PARAMETER_NAME(arg2) 9 | 10 | struct callable2 11 | { 12 | BOOST_PARAMETER_CONST_FUNCTION_CALL_OPERATOR( 13 | (void), tag, (required (arg1,(int))(arg2,(int))) 14 | ) 15 | { 16 | std::cout << arg1 << ", " << arg2 << std::endl; 17 | } 18 | }; 19 | 20 | #include 21 | 22 | int main() 23 | { 24 | callable2 c2; 25 | callable2 const& c2_const = c2; 26 | c2_const(1, 2); 27 | return boost::report_errors(); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /test/literate/parameter-enabled-member-functions0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | using namespace boost::parameter; 6 | 7 | BOOST_PARAMETER_NAME(arg1) 8 | BOOST_PARAMETER_NAME(arg2) 9 | 10 | struct callable2 11 | { 12 | BOOST_PARAMETER_CONST_MEMBER_FUNCTION( 13 | (void), call, tag, (required (arg1,(int))(arg2,(int))) 14 | ) 15 | { 16 | std::cout << arg1 << ", " << arg2 << std::endl; 17 | } 18 | }; 19 | 20 | #include 21 | 22 | int main() 23 | { 24 | callable2 c2; 25 | callable2 const& c2_const = c2; 26 | c2_const.call(1, 2); 27 | return boost::report_errors(); 28 | } 29 | 30 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/as_lvalue.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_AS_LVALUE_HPP 7 | #define BOOST_PARAMETER_AUX_AS_LVALUE_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | template 12 | T const& as_lvalue(T const& value) 13 | { 14 | return value; 15 | } 16 | 17 | template 18 | T& as_lvalue(T& value) 19 | { 20 | return value; 21 | } 22 | }}} // namespace boost::parameter::aux 23 | 24 | #endif // include guard 25 | 26 | -------------------------------------------------------------------------------- /test/literate/namespaces3.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | namespace lib { 6 | namespace keywords { 7 | 8 | BOOST_PARAMETER_NAME(name) 9 | BOOST_PARAMETER_NAME(index) 10 | } 11 | 12 | BOOST_PARAMETER_FUNCTION( 13 | (int), f, keywords::tag, (optional (name,*,"bob")(index,(int),1)) 14 | ) 15 | { 16 | std::cout << name << ":" << index << std::endl; 17 | return index; 18 | } 19 | } 20 | 21 | #include 22 | 23 | using namespace lib::keywords; 24 | 25 | int main() 26 | { 27 | int x = lib::f(_name = "bob", _index = 2); 28 | BOOST_TEST_EQ(x, 2); 29 | return boost::report_errors(); 30 | } 31 | 32 | -------------------------------------------------------------------------------- /include/boost/parameter/keyword_fwd.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Cromwell D. Enage 2017. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_KEYWORD_FWD_HPP 7 | #define BOOST_PARAMETER_KEYWORD_FWD_HPP 8 | 9 | namespace boost { namespace parameter { 10 | 11 | struct in_reference; 12 | struct out_reference; 13 | typedef ::boost::parameter::out_reference in_out_reference; 14 | struct forward_reference; 15 | struct consume_reference; 16 | typedef ::boost::parameter::consume_reference move_from_reference; 17 | 18 | template 19 | struct keyword; 20 | }} // namespace boost::parameter 21 | 22 | #endif // include guard 23 | 24 | -------------------------------------------------------------------------------- /test/literate/lazy-default-computation0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | BOOST_PARAMETER_NAME(s1) 6 | BOOST_PARAMETER_NAME(s2) 7 | BOOST_PARAMETER_NAME(s3) 8 | 9 | template 10 | std::string f(ArgumentPack const& args) 11 | { 12 | std::string const& s1 = args[_s1]; 13 | std::string const& s2 = args[_s2]; 14 | typename boost::parameter::binding< 15 | ArgumentPack,tag::s3,std::string 16 | >::type s3 = args[_s3|(s1+s2)]; // always constructs s1+s2 17 | return s3; 18 | } 19 | 20 | #include 21 | 22 | int main() 23 | { 24 | std::string x = f((_s1="hello,", _s2=" world", _s3="hi world")); 25 | BOOST_TEST_EQ(x, std::string("hi world")); 26 | return boost::report_errors(); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /test/deduced_unmatched_arg.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | BOOST_PARAMETER_NAME(x) 14 | 15 | int main() 16 | { 17 | boost::parameter::parameters< 18 | boost::parameter::optional< 19 | boost::parameter::deduced 20 | , boost::is_convertible 21 | > 22 | >()("foo"); 23 | return 0; 24 | } 25 | 26 | -------------------------------------------------------------------------------- /test/literate/optional-parameters0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | namespace boost { 5 | 6 | int vertex_index = 0; 7 | 8 | template 9 | struct dfs_visitor 10 | { 11 | }; 12 | } 13 | 14 | BOOST_PARAMETER_NAME(graph) 15 | BOOST_PARAMETER_NAME(visitor) 16 | BOOST_PARAMETER_NAME(root_vertex) 17 | BOOST_PARAMETER_NAME(index_map) 18 | BOOST_PARAMETER_NAME(in_out(color_map)) 19 | 20 | BOOST_PARAMETER_FUNCTION((void), f, tag, 21 | (required (graph, *)) 22 | (optional 23 | (visitor, *, boost::dfs_visitor<>()) 24 | (root_vertex, *, *vertices(graph).first) 25 | (index_map, *, get(boost::vertex_index,graph)) 26 | (color_map, *, 27 | default_color_map(num_vertices(graph), index_map) 28 | ) 29 | ) 30 | ) 31 | { 32 | } 33 | 34 | -------------------------------------------------------------------------------- /doc/html/rst.css: -------------------------------------------------------------------------------- 1 | /* Copyright David Abrahams 2006. Distributed under the Boost 2 | Software License, Version 1.0. (See accompanying 3 | file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | */ 5 | 6 | @import "../../../../rst.css"; 7 | 8 | div.section div.section div.section dl { 9 | margin-left: 2em; 10 | } 11 | 12 | td span { 13 | vertical-align: text-top; 14 | } 15 | 16 | img { 17 | border: none; 18 | vertical-align: middle 19 | } 20 | 21 | span.vellipsis { 22 | display: block; 23 | width: 5px; 24 | height: 22px; 25 | background: url("vellipsis.gif"); 26 | margin-left: 3em; 27 | text-indent: -1000px; 28 | } 29 | 30 | 31 | PRE 32 | { 33 | FONT-FAMILY: monospace ; 34 | } 35 | 36 | CODE 37 | { 38 | FONT-FAMILY: monospace; 39 | } 40 | .pre 41 | { 42 | FONT-FAMILY: monospace; 43 | } 44 | -------------------------------------------------------------------------------- /test/literate/handling-out-parameters0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | namespace boost { 5 | 6 | int vertex_index = 0; 7 | 8 | template 9 | struct dfs_visitor 10 | { 11 | }; 12 | } 13 | 14 | BOOST_PARAMETER_NAME(graph) 15 | BOOST_PARAMETER_NAME(visitor) 16 | BOOST_PARAMETER_NAME(root_vertex) 17 | BOOST_PARAMETER_NAME(index_map) 18 | BOOST_PARAMETER_NAME(in_out(color_map)) 19 | 20 | BOOST_PARAMETER_FUNCTION((void), f, tag, 21 | (required (graph, *)) 22 | (optional 23 | (visitor, *, boost::dfs_visitor<>()) 24 | (root_vertex, *, *vertices(graph).first) 25 | (index_map, *, get(boost::vertex_index,graph)) 26 | (color_map, *, 27 | default_color_map(num_vertices(graph), index_map) 28 | ) 29 | ) 30 | ) 31 | { 32 | } 33 | 34 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/insert_tagged.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_INSERT_TAGGED_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_INSERT_TAGGED_HPP 8 | 9 | #include 10 | 11 | namespace boost { namespace parameter { namespace aux { 12 | 13 | // Inserts Tagged::key_type into the UserArgs set. 14 | // Extra indirection to lazily evaluate Tagged::key_type. 15 | template 16 | struct insert_tagged 17 | : ::boost::parameter::aux::insert_ 18 | { 19 | }; 20 | }}} // namespace boost::parameter::aux 21 | 22 | #endif // include guard 23 | 24 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/use_default_tag.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_USE_DEFAULT_TAG_HPP 7 | #define BOOST_PARAMETER_USE_DEFAULT_TAG_HPP 8 | 9 | #include 10 | 11 | namespace boost { namespace parameter { namespace aux { 12 | 13 | struct use_default_tag 14 | { 15 | inline BOOST_CONSTEXPR BOOST_DEFAULTED_FUNCTION(use_default_tag(), {}) 16 | 17 | inline BOOST_CONSTEXPR BOOST_DEFAULTED_FUNCTION( 18 | use_default_tag(use_default_tag const&), {} 19 | ) 20 | 21 | inline BOOST_CONSTEXPR use_default_tag operator()() const 22 | { 23 | return *this; 24 | } 25 | }; 26 | }}} // namespace boost::parameter::aux 27 | 28 | #endif // include guard 29 | 30 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Generated by `boostdep --cmake parameter` 2 | # Copyright 2020 Peter Dimov 3 | # Distributed under the Boost Software License, Version 1.0. 4 | # https://www.boost.org/LICENSE_1_0.txt 5 | 6 | cmake_minimum_required(VERSION 3.5...3.16) 7 | 8 | project(boost_parameter VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX) 9 | 10 | add_library(boost_parameter INTERFACE) 11 | add_library(Boost::parameter ALIAS boost_parameter) 12 | 13 | target_include_directories(boost_parameter INTERFACE include) 14 | 15 | target_link_libraries(boost_parameter 16 | INTERFACE 17 | Boost::config 18 | Boost::core 19 | Boost::function 20 | Boost::fusion 21 | Boost::mp11 22 | Boost::mpl 23 | Boost::optional 24 | Boost::preprocessor 25 | Boost::type_traits 26 | Boost::utility 27 | ) 28 | 29 | if(BUILD_TESTING AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/test/CMakeLists.txt") 30 | 31 | add_subdirectory(test) 32 | 33 | endif() 34 | 35 | -------------------------------------------------------------------------------- /doc/Jamfile.v2: -------------------------------------------------------------------------------- 1 | # Copyright David Abrahams 2006. Distributed under the Boost 2 | # Software License, Version 1.0. (See accompanying 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | import docutils ; 6 | 7 | sources = [ glob *.rst ] ; 8 | bases = $(sources:S=) ; 9 | 10 | # This is a path relative to the html/ subdirectory where the 11 | # generated output will eventually be moved. 12 | stylesheet = "--stylesheet=rst.css" ; 13 | 14 | for local b in $(bases) 15 | { 16 | html $(b) : $(b).rst : 17 | 18 | # 19 | "-gdt --link-stylesheet --traceback --trim-footnote-reference-space --footnote-references=superscript "$(stylesheet) 20 | ; 21 | } 22 | 23 | alias htmls : $(bases) ; 24 | stage html : $(bases) ; 25 | 26 | ############################################################################### 27 | alias boostdoc ; 28 | explicit boostdoc ; 29 | alias boostrelease : html ; 30 | explicit boostrelease ; 31 | -------------------------------------------------------------------------------- /include/boost/parameter/is_argument_pack.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Cromwell D. Enage 2018. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_IS_ARGUMENT_PACK_HPP 7 | #define BOOST_PARAMETER_IS_ARGUMENT_PACK_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace boost { namespace parameter { 16 | 17 | template 18 | struct is_argument_pack 19 | : ::boost::mpl::if_< 20 | ::boost::is_base_of< ::boost::parameter::aux::empty_arg_list,T> 21 | , ::boost::mpl::true_ 22 | , ::boost::parameter::aux::is_tagged_argument 23 | >::type 24 | { 25 | }; 26 | }} 27 | 28 | #endif // include guard 29 | 30 | -------------------------------------------------------------------------------- /test/literate/parameter-enabled-constructors0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | BOOST_PARAMETER_NAME(name) 6 | BOOST_PARAMETER_NAME(index) 7 | 8 | struct myclass_impl 9 | { 10 | template 11 | myclass_impl(ArgumentPack const& args) 12 | { 13 | std::cout << "name = " << args[_name]; 14 | std::cout << "; index = " << args[_index | 42]; 15 | std::cout << std::endl; 16 | } 17 | }; 18 | 19 | struct myclass : myclass_impl 20 | { 21 | BOOST_PARAMETER_CONSTRUCTOR( 22 | myclass, (myclass_impl), tag 23 | , (required (name,*)) (optional (index,*)) 24 | ) // no semicolon 25 | }; 26 | 27 | #include 28 | 29 | int main() 30 | { 31 | myclass x("bob", 3); // positional 32 | myclass y(_index = 12, _name = "sally"); // named 33 | myclass z("june"); // positional/defaulted 34 | return boost::report_errors(); 35 | } 36 | 37 | -------------------------------------------------------------------------------- /test/literate/lazy-default-computation1.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | BOOST_PARAMETER_NAME(s1) 9 | BOOST_PARAMETER_NAME(s2) 10 | BOOST_PARAMETER_NAME(s3) 11 | 12 | template 13 | std::string f(ArgumentPack const& args) 14 | { 15 | std::string const& s1 = args[_s1]; 16 | std::string const& s2 = args[_s2]; 17 | typename boost::parameter::binding< 18 | ArgumentPack, tag::s3, std::string 19 | >::type s3 = args[ 20 | _s3 || boost::bind( 21 | std::plus() 22 | , boost::ref(s1) 23 | , boost::ref(s2) 24 | ) 25 | ]; 26 | return s3; 27 | } 28 | 29 | #include 30 | 31 | int main() 32 | { 33 | std::string x = f((_s1="hello,", _s2=" world", _s3="hi world")); 34 | BOOST_TEST_EQ(x, std::string("hi world")); 35 | return boost::report_errors(); 36 | } 37 | 38 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/seq_enum.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_SEQ_ENUM_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_SEQ_ENUM_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #if BOOST_WORKAROUND(__MWERKS__, <= 0x3003) 14 | #include 15 | // Temporary version of BOOST_PP_SEQ_ENUM 16 | // until Paul M. integrates the workaround. 17 | #define BOOST_PARAMETER_SEQ_ENUM_I(size, seq) \ 18 | BOOST_PP_CAT(BOOST_PP_SEQ_ENUM_, size) seq 19 | #define BOOST_PARAMETER_SEQ_ENUM(seq) \ 20 | BOOST_PARAMETER_SEQ_ENUM_I(BOOST_PP_SEQ_SIZE(seq), seq) 21 | #else 22 | #define BOOST_PARAMETER_SEQ_ENUM(seq) BOOST_PP_SEQ_ENUM(seq) 23 | #endif 24 | 25 | #endif // include guard 26 | 27 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/tag_keyword_arg.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_TAG_KEYWORD_ARG_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_TAG_KEYWORD_ARG_HPP 8 | 9 | #include 10 | #include 11 | 12 | namespace boost { namespace parameter { namespace aux { 13 | 14 | struct tag_keyword_arg 15 | { 16 | template 17 | struct apply 18 | { 19 | typedef typename ::boost::parameter::aux::tag::type type; 20 | }; 21 | 22 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 23 | template 24 | using fn = typename ::boost::parameter::aux::tag::type; 25 | #endif 26 | }; 27 | }}} // namespace boost::parameter::aux 28 | 29 | #endif // include guard 30 | 31 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/parameter_requirements.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin, David Abrahams 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_PARAMETER_REQUIREMENTS_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_PARAMETER_REQUIREMENTS_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | // Used to pass static information about parameter requirements through 12 | // the satisfies() overload set (below). The matched function is never 13 | // invoked, but its type indicates whether a parameter matches at 14 | // compile-time. 15 | template 16 | struct parameter_requirements 17 | { 18 | typedef Keyword keyword; 19 | typedef Predicate predicate; 20 | typedef HasDefault has_default; 21 | }; 22 | }}} // namespace boost::parameter::aux 23 | 24 | #endif // include guard 25 | 26 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/tag_template_keyword_arg.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_TAG_TEMPLATE_KEYWORD_ARG_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_TAG_TEMPLATE_KEYWORD_ARG_HPP 8 | 9 | #include 10 | #include 11 | 12 | namespace boost { namespace parameter { namespace aux { 13 | 14 | struct tag_template_keyword_arg 15 | { 16 | template 17 | struct apply 18 | { 19 | typedef ::boost::parameter::template_keyword type; 20 | }; 21 | 22 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 23 | template 24 | using fn = ::boost::parameter::template_keyword; 25 | #endif 26 | }; 27 | }}} // namespace boost::parameter::aux 28 | 29 | #endif // include guard 30 | 31 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/no_perfect_forwarding_end.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Copyright Cromwell D. Enage 2017. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // No include guard. This file is intended for multiple inclusion. 8 | 9 | #undef BOOST_PARAMETER_satisfies_begin 10 | #if (0 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY) 11 | #undef BOOST_PARAMETER_function_call_op_overload_R 12 | #undef BOOST_PARAMETER_function_call_arg_pack_init 13 | #undef BOOST_PARAMETER_function_call_arg_list_R 14 | #undef BOOST_PARAMETER_make_arg_items_R 15 | #endif 16 | #undef BOOST_PARAMETER_template_args 17 | #undef BOOST_PARAMETER_forward_typedef 18 | #undef BOOST_PARAMETER_build_deduced_list 19 | #undef BOOST_PARAMETER_make_deduced_list 20 | #undef BOOST_PARAMETER_build_arg_list 21 | #undef BOOST_PARAMETER_make_arg_list 22 | #undef BOOST_PARAMETER_satisfies_end 23 | #undef BOOST_PARAMETER_right_angle 24 | 25 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/impl/argument_specs.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_ARGUMENT_SPECS_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_ARGUMENT_SPECS_HPP 8 | 9 | #include 10 | 11 | // Accessor macros for the argument specs tuple. 12 | #define BOOST_PARAMETER_FN_ARG_QUALIFIER(x) BOOST_PP_TUPLE_ELEM(4, 0, x) 13 | #define BOOST_PARAMETER_FN_ARG_KEYWORD(x) BOOST_PP_TUPLE_ELEM(4, 1, x) 14 | #define BOOST_PARAMETER_FN_ARG_PRED(x) BOOST_PP_TUPLE_ELEM(4, 2, x) 15 | #define BOOST_PARAMETER_FN_ARG_DEFAULT(x) BOOST_PP_TUPLE_ELEM(4, 3, x) 16 | 17 | #include 18 | 19 | #define BOOST_PARAMETER_FN_ARG_NAME(x) \ 20 | BOOST_PARAMETER_UNQUALIFIED(BOOST_PARAMETER_FN_ARG_KEYWORD(x)) 21 | /**/ 22 | 23 | #endif // include guard 24 | 25 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/deduced_item.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_DEDUCED_ITEM_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_DEDUCED_ITEM_HPP 8 | 9 | #include 10 | 11 | namespace boost { namespace parameter { namespace aux { 12 | 13 | // A typelist that stored deduced parameter specs. 14 | template < 15 | typename ParameterSpec 16 | , typename Tail = ::boost::parameter::void_ 17 | > 18 | struct deduced_item 19 | { 20 | typedef ParameterSpec spec; 21 | typedef Tail tail; 22 | }; 23 | 24 | // Evaluate Tail and construct deduced_item list. 25 | template 26 | struct make_deduced_item 27 | { 28 | typedef ::boost::parameter::aux 29 | ::deduced_item type; 30 | }; 31 | }}} // namespace boost::parameter::aux 32 | 33 | #endif // include guard 34 | 35 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/void.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin, David Abrahams 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_VOID_050329_HPP 7 | #define BOOST_PARAMETER_VOID_050329_HPP 8 | 9 | namespace boost { namespace parameter { 10 | 11 | // A placemarker for "no argument passed." 12 | // MAINTAINER NOTE: Do not make this into a metafunction 13 | struct void_ 14 | { 15 | }; 16 | }} // namespace boost::parameter 17 | 18 | namespace boost { namespace parameter { namespace aux { 19 | 20 | inline ::boost::parameter::void_& void_reference() 21 | { 22 | static ::boost::parameter::void_ instance; 23 | return instance; 24 | } 25 | }}} // namespace boost::parameter::aux 26 | 27 | #include 28 | 29 | #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) 30 | 31 | namespace boost { namespace parameter { namespace aux { 32 | 33 | typedef void* voidstar; 34 | }}} // namespace boost::parameter::aux 35 | 36 | #endif 37 | #endif // include guard 38 | 39 | -------------------------------------------------------------------------------- /test/maybe.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | 8 | namespace test { 9 | 10 | BOOST_PARAMETER_NAME(kw) 11 | BOOST_PARAMETER_NAME(unused) 12 | 13 | template 14 | int f(Args const& args) 15 | { 16 | return args[test::_kw | 1.f]; 17 | } 18 | } // namespace test 19 | 20 | #include 21 | #include 22 | 23 | int main() 24 | { 25 | BOOST_TEST_EQ(0, test::f((test::_kw = 0, test::_unused = 0))); 26 | BOOST_TEST_EQ(1, test::f(test::_unused = 0)); 27 | BOOST_TEST_EQ( 28 | 1 29 | , test::f(( 30 | test::_kw = boost::parameter::aux::maybe() 31 | , test::_unused = 0 32 | )) 33 | ); 34 | BOOST_TEST_EQ( 35 | 2 36 | , test::f(( 37 | test::_kw = boost::parameter::aux::maybe(2) 38 | , test::_unused = 0 39 | )) 40 | ); 41 | return boost::report_errors(); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/is_binary.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IS_BINARY_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_IS_BINARY_HPP 8 | 9 | #include 10 | #include 11 | 12 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) 13 | // From Paul Mensonides 14 | #include 15 | #include 16 | #define BOOST_PARAMETER_IS_BINARY(x) \ 17 | BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_BINARY_C x BOOST_PP_COMMA() 0) 18 | /**/ 19 | #include 20 | #include 21 | #define BOOST_PARAMETER_IS_BINARY_C(x,y) \ 22 | ~, 1 BOOST_PP_RPAREN() \ 23 | BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ 24 | /**/ 25 | #else 26 | #include 27 | #define BOOST_PARAMETER_IS_BINARY(x) BOOST_PP_IS_BINARY(x) 28 | #endif 29 | 30 | #endif // include guard 31 | 32 | -------------------------------------------------------------------------------- /include/boost/parameter.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // See www.boost.org/libs/parameter for documentation. 7 | 8 | #ifndef BOOST_PARAMETER_050401_HPP 9 | #define BOOST_PARAMETER_050401_HPP 10 | 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #endif // include guard 30 | 31 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/is_nullary.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IS_NULLARY_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_IS_NULLARY_HPP 8 | 9 | #include 10 | #include 11 | 12 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) 13 | // From Paul Mensonides 14 | #include 15 | #include 16 | #define BOOST_PARAMETER_IS_NULLARY(x) \ 17 | BOOST_PP_SPLIT(1, BOOST_PARAMETER_IS_NULLARY_C x BOOST_PP_COMMA() 0) 18 | /**/ 19 | #include 20 | #include 21 | #define BOOST_PARAMETER_IS_NULLARY_C() \ 22 | ~, 1 BOOST_PP_RPAREN() \ 23 | BOOST_PP_TUPLE_EAT(2) BOOST_PP_LPAREN() ~ 24 | /**/ 25 | #else 26 | #include 27 | #define BOOST_PARAMETER_IS_NULLARY(x) BOOST_PP_IS_NULLARY(x) 28 | /**/ 29 | #endif 30 | 31 | #endif // include guard 32 | 33 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/tagged_argument_fwd.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin, David Abrahams 2005. 2 | // Copyright Cromwell D. Enage 2017. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_PARAMETER_TAGGED_ARGUMENT_FWD_HPP 8 | #define BOOST_PARAMETER_TAGGED_ARGUMENT_FWD_HPP 9 | 10 | namespace boost { namespace parameter { namespace aux { 11 | 12 | template 13 | class tagged_argument; 14 | }}} // namespace boost::parameter::aux 15 | 16 | #include 17 | 18 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 19 | 20 | namespace boost { namespace parameter { namespace aux { 21 | 22 | template 23 | struct tagged_argument_rref; 24 | }}} // namespace boost::parameter::aux 25 | 26 | #endif 27 | 28 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 29 | 30 | namespace boost { namespace parameter { namespace aux { 31 | 32 | template 33 | struct tagged_argument_list_of_1; 34 | }}} // namespace boost::parameter::aux 35 | 36 | #endif 37 | #endif // include guard 38 | 39 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/impl/function_dispatch_tuple.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_DISPATCH_TUPLE_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_DISPATCH_TUPLE_HPP 8 | 9 | #include 10 | 11 | // Accessor macros for the input tuple to the dispatch macros. 12 | #define BOOST_PARAMETER_FUNCTION_DISPATCH_BASE_NAME(x) \ 13 | BOOST_PP_TUPLE_ELEM(5, 0, x) 14 | /**/ 15 | 16 | #define BOOST_PARAMETER_FUNCTION_DISPATCH_SPLIT_ARGS(x) \ 17 | BOOST_PP_TUPLE_ELEM(5, 1, x) 18 | /**/ 19 | 20 | #define BOOST_PARAMETER_FUNCTION_DISPATCH_IS_MEMBER(x) \ 21 | BOOST_PP_TUPLE_ELEM(5, 2, x) 22 | /**/ 23 | 24 | #define BOOST_PARAMETER_FUNCTION_DISPATCH_IS_CONST(x) \ 25 | BOOST_PP_TUPLE_ELEM(5, 3, x) 26 | /**/ 27 | 28 | #define BOOST_PARAMETER_FUNCTION_DISPATCH_TAG_NAMESPACE(x) \ 29 | BOOST_PP_TUPLE_ELEM(5, 4, x) 30 | /**/ 31 | 32 | #endif // include guard 33 | 34 | -------------------------------------------------------------------------------- /test/literate/default-expression-evaluation0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | BOOST_PARAMETER_NAME(graph) 6 | BOOST_PARAMETER_NAME(visitor) 7 | BOOST_PARAMETER_NAME(root_vertex) 8 | BOOST_PARAMETER_NAME(index_map) 9 | BOOST_PARAMETER_NAME(color_map) 10 | 11 | BOOST_PARAMETER_FUNCTION((bool), depth_first_search, tag, 12 | (required 13 | (graph, *) 14 | (visitor, *) 15 | (root_vertex, *) 16 | (index_map, *) 17 | (color_map, *) 18 | ) 19 | ) 20 | { 21 | std::cout << "graph=" << graph; 22 | std::cout << std::endl; 23 | std::cout << "visitor=" << visitor; 24 | std::cout << std::endl; 25 | std::cout << "root_vertex=" << root_vertex; 26 | std::cout << std::endl; 27 | std::cout << "index_map=" << index_map; 28 | std::cout << std::endl; 29 | std::cout << "color_map=" << color_map; 30 | std::cout << std::endl; 31 | return true; 32 | } 33 | 34 | #include 35 | 36 | int main() 37 | { 38 | char const* g = "1"; 39 | depth_first_search(1, 2, 3, 4, 5); 40 | depth_first_search( 41 | g, '2', _color_map = '5' 42 | , _index_map = "4", _root_vertex = "3" 43 | ); 44 | return boost::report_errors(); 45 | } 46 | 47 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/impl/parenthesized_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_PARENTHESIZED_TYPE_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_PARENTHESIZED_TYPE_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | // A metafunction that transforms void(*)(T) -> T 12 | template 13 | struct unaryfunptr_arg_type; 14 | 15 | template 16 | struct unaryfunptr_arg_type 17 | { 18 | typedef Arg type; 19 | }; 20 | 21 | template <> 22 | struct unaryfunptr_arg_type 23 | { 24 | typedef void type; 25 | }; 26 | }}} // namespace boost::parameter::aux 27 | 28 | // A macro that takes a parenthesized C++ type name (T) and transforms it 29 | // into an un-parenthesized type expression equivalent to T. 30 | #define BOOST_PARAMETER_PARENTHESIZED_TYPE(x) \ 31 | ::boost::parameter::aux::unaryfunptr_arg_type< void(*)x >::type 32 | 33 | #endif // include guard 34 | 35 | -------------------------------------------------------------------------------- /test/literate/top-level0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | namespace test { 5 | 6 | BOOST_PARAMETER_NAME(title) 7 | BOOST_PARAMETER_NAME(width) 8 | BOOST_PARAMETER_NAME(titlebar) 9 | 10 | BOOST_PARAMETER_FUNCTION((int), new_window, tag, 11 | (required (title,*)(width,*)(titlebar,*)) 12 | ) 13 | { 14 | return 0; 15 | } 16 | 17 | BOOST_PARAMETER_TEMPLATE_KEYWORD(deleter) 18 | BOOST_PARAMETER_TEMPLATE_KEYWORD(copy_policy) 19 | 20 | template 21 | struct Deallocate 22 | { 23 | }; 24 | 25 | struct DeepCopy 26 | { 27 | }; 28 | 29 | struct Foo 30 | { 31 | }; 32 | 33 | template 34 | struct smart_ptr 35 | { 36 | smart_ptr(test::Foo*) 37 | { 38 | } 39 | }; 40 | } 41 | 42 | #include 43 | 44 | int main() 45 | { 46 | char const* alert_s = "alert"; 47 | int x = test::new_window(alert_s, test::_width=10, test::_titlebar=false); 48 | test::Foo* foo = new test::Foo(); 49 | test::smart_ptr< 50 | test::Foo 51 | , test::deleter > 52 | , test::copy_policy 53 | > p(foo); 54 | delete foo; 55 | return boost::report_errors(); 56 | } 57 | 58 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/unmatched_argument.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_UNMATCHED_ARGUMENT_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_UNMATCHED_ARGUMENT_HPP 8 | 9 | #include 10 | 11 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 12 | #include 13 | #else 14 | #include 15 | #include 16 | #include 17 | #include 18 | #endif 19 | 20 | namespace boost { namespace parameter { namespace aux { 21 | 22 | template 23 | struct unmatched_argument 24 | { 25 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 26 | static_assert(::std::is_same::value, "T == void"); 27 | #else 28 | BOOST_MPL_ASSERT(( 29 | typename ::boost::mpl::if_< 30 | ::boost::is_same 31 | , ::boost::mpl::true_ 32 | , ::boost::mpl::false_ 33 | >::type 34 | )); 35 | #endif 36 | typedef int type; 37 | }; 38 | }}} // namespace boost::parameter::aux 39 | 40 | #endif // include guard 41 | 42 | -------------------------------------------------------------------------------- /test/tutorial.cpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | 8 | namespace graphs { 9 | 10 | BOOST_PARAMETER_NAME(graph) // Note: no semicolon 11 | BOOST_PARAMETER_NAME(visitor) 12 | BOOST_PARAMETER_NAME(root_vertex) 13 | BOOST_PARAMETER_NAME(index_map) 14 | BOOST_PARAMETER_NAME(color_map) 15 | } // namespace graphs 16 | 17 | #include 18 | 19 | namespace graphs { namespace core { 20 | 21 | template 22 | void depth_first_search(ArgumentPack const& args) 23 | { 24 | BOOST_TEST_EQ(false, args[_color_map]); 25 | BOOST_TEST_EQ('G', args[_graph]); 26 | BOOST_TEST_CSTR_EQ("hello, world", args[_index_map]); 27 | BOOST_TEST_EQ(3.5, args[_root_vertex]); 28 | BOOST_TEST_EQ(2, args[_visitor]); 29 | } 30 | }} // namespace graphs::core 31 | 32 | int main() 33 | { 34 | using namespace graphs; 35 | 36 | core::depth_first_search(( 37 | _graph = 'G', _visitor = 2, _root_vertex = 3.5 38 | , _index_map = "hello, world", _color_map = false 39 | )); 40 | return boost::report_errors(); 41 | } 42 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/always_true_predicate.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Cromwell D. Enage 2019. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_ALWAYS_TRUE_PREDICATE_HPP 7 | #define BOOST_PARAMETER_AUX_ALWAYS_TRUE_PREDICATE_HPP 8 | 9 | #include 10 | #include 11 | 12 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 13 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 14 | #include 15 | #endif 16 | #else 17 | #include 18 | #endif 19 | 20 | namespace boost { namespace parameter { namespace aux { 21 | 22 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 23 | struct always_true_predicate 24 | { 25 | template 26 | struct apply 27 | { 28 | typedef ::boost::mpl::true_ type; 29 | }; 30 | 31 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 32 | template 33 | using fn = ::boost::mp11::mp_true; 34 | #endif 35 | }; 36 | #else 37 | typedef ::boost::mpl::always< ::boost::mpl::true_> always_true_predicate; 38 | #endif // BOOST_NO_CXX11_VARIADIC_TEMPLATES 39 | }}} // namespace boost::parameter::aux 40 | 41 | #endif // include guard 42 | 43 | -------------------------------------------------------------------------------- /test/literate/extracting-parameter-types0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | BOOST_PARAMETER_NAME(name) 5 | BOOST_PARAMETER_NAME(index) 6 | 7 | template 8 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 9 | void noop(T&&) 10 | #else 11 | void noop(T&) 12 | #endif 13 | { 14 | } 15 | 16 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 17 | #include 18 | #endif 19 | 20 | template 21 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 22 | int deduce_arg_types_impl(Name&& name, Index&& index) 23 | { 24 | noop(std::forward(name)); 25 | noop(std::forward(index)); 26 | return index; 27 | } 28 | #else 29 | int deduce_arg_types_impl(Name& name, Index& index) 30 | { 31 | Name& n2 = name; // we know the types 32 | Index& i2 = index; 33 | noop(n2); 34 | noop(i2); 35 | return index; 36 | } 37 | #endif 38 | 39 | template 40 | int deduce_arg_types(ArgumentPack const& args) 41 | { 42 | return deduce_arg_types_impl(args[_name], args[_index|42]); 43 | } 44 | 45 | #include 46 | 47 | int main() 48 | { 49 | int a1 = deduce_arg_types((_name = "foo")); 50 | int a2 = deduce_arg_types((_name = "foo", _index = 3)); 51 | BOOST_TEST_EQ(a1, 42); 52 | BOOST_TEST_EQ(a2, 3); 53 | return boost::report_errors(); 54 | } 55 | 56 | -------------------------------------------------------------------------------- /test/literate/writing-the-function0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | BOOST_PARAMETER_NAME(graph) 5 | BOOST_PARAMETER_NAME(visitor) 6 | BOOST_PARAMETER_NAME(root_vertex) 7 | BOOST_PARAMETER_NAME(index_map) 8 | BOOST_PARAMETER_NAME(in_out(color_map)) 9 | 10 | namespace boost { 11 | 12 | template 13 | struct dfs_visitor 14 | { 15 | }; 16 | 17 | int vertex_index = 0; 18 | } 19 | 20 | #include 21 | 22 | namespace graphs { 23 | 24 | BOOST_PARAMETER_FUNCTION( 25 | (void), // 1. parenthesized return type 26 | depth_first_search, // 2. name of the function template 27 | 28 | tag, // 3. namespace of tag types 29 | 30 | (required (graph, *) ) // 4. one required parameter, and 31 | 32 | (optional // four optional parameters, with defaults 33 | (visitor, *, boost::dfs_visitor<>()) 34 | (root_vertex, *, *vertices(graph).first) 35 | (index_map, *, get(boost::vertex_index,graph)) 36 | (in_out(color_map), *, 37 | default_color_map(num_vertices(graph), index_map) 38 | ) 39 | ) 40 | ) 41 | { 42 | // ... body of function goes here... 43 | // use graph, visitor, index_map, and color_map 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright 2019 Mike Dev 2 | # Distributed under the Boost Software License, Version 1.0. 3 | # See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt 4 | # 5 | # NOTE: CMake support for Boost.Parameter is currently experimental at best 6 | # and the interface is likely to change in the future 7 | 8 | include_directories(${CMAKE_CURRENT_SOURCE_DIR}) 9 | 10 | # TODO: Also process literate tests 11 | file(GLOB test_files *.cpp) 12 | 13 | # remove some test for which the dependencies are not yet available or have 14 | # special requirements 15 | # TODO: enable more tests 16 | list(FILTER test_files EXCLUDE REGEX 17 | efficiency|deduced_unmatched_arg|duplicates) 18 | 19 | # Attach all our tests to the `tests` target, to enable 20 | # `cmake --build . --target tests` 21 | if(NOT TARGET tests) 22 | add_custom_target(tests) 23 | endif() 24 | 25 | foreach(file IN LISTS test_files) 26 | 27 | get_filename_component(core_name ${file} NAME_WE) 28 | set(test_name boost_parameter-test-${core_name}) 29 | 30 | add_executable(${test_name} EXCLUDE_FROM_ALL ${file}) 31 | add_dependencies(tests ${test_name}) 32 | 33 | # add Boost.Parameter and any libraries that are only needed by the tests 34 | # (none at the moment) 35 | target_link_libraries(${test_name} Boost::parameter) 36 | 37 | add_test(NAME ${test_name} COMMAND ${test_name}) 38 | 39 | endforeach() 40 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/as_parameter_requirements.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_AS_PARAMETER_REQUIREMENTS_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_AS_PARAMETER_REQUIREMENTS_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace boost { namespace parameter { namespace aux { 15 | 16 | // Converts a ParameterSpec into a specialization of 17 | // parameter_requirements. We need to do this in order to get the 18 | // tag_type into the type in a way that can be conveniently matched 19 | // by a satisfies(...) member function in arg_list. 20 | template 21 | struct as_parameter_requirements 22 | { 23 | typedef ::boost::parameter::aux::parameter_requirements< 24 | typename ::boost::parameter::aux::tag_type::type 25 | , typename ::boost::parameter::aux::predicate::type 26 | , ::boost::parameter::aux::has_default 27 | > type; 28 | }; 29 | }}} // namespace boost::parameter::aux 30 | 31 | #endif // include guard 32 | 33 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/is_named_argument.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_IS_NAMED_ARGUMENT_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_IS_NAMED_ARGUMENT_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 14 | #include 15 | #include 16 | #else 17 | #include 18 | #include 19 | #endif 20 | 21 | namespace boost { namespace parameter { namespace aux { 22 | 23 | template 24 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 25 | using is_named_argument = ::boost::mp11::mp_if< 26 | ::boost::parameter::aux::is_template_keyword 27 | , ::boost::mp11::mp_true 28 | , ::boost::parameter::aux::is_tagged_argument_mp11 29 | >; 30 | #else 31 | struct is_named_argument 32 | : ::boost::mpl::if_< 33 | ::boost::parameter::aux::is_template_keyword 34 | , ::boost::mpl::true_ 35 | , ::boost::parameter::aux::is_tagged_argument 36 | >::type 37 | { 38 | }; 39 | #endif 40 | }}} // namespace boost::parameter::aux 41 | 42 | #endif // include guard 43 | 44 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/item.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_ITEM_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_ITEM_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) 14 | #include 15 | #include 16 | #endif 17 | 18 | namespace boost { namespace parameter { namespace aux { 19 | 20 | // A parameter spec item typelist. 21 | template < 22 | typename Spec 23 | , typename Arg 24 | , typename Tail = ::boost::parameter::void_ 25 | > 26 | struct item 27 | { 28 | typedef Spec spec; 29 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) 30 | typedef ::boost::is_const< 31 | typename ::boost::remove_reference::type 32 | > is_arg_const; 33 | #endif 34 | typedef Arg arg; 35 | typedef Tail tail; 36 | }; 37 | 38 | template 39 | struct make_item 40 | { 41 | typedef boost::parameter::aux 42 | ::item type; 43 | }; 44 | }}} // namespace boost::parameter::aux 45 | 46 | #endif // include guard 47 | 48 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/make_items.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_MAKE_ITEMS_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_MAKE_ITEMS_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 14 | #include 15 | #include 16 | #else 17 | #include 18 | #include 19 | #include 20 | #endif 21 | 22 | namespace boost { namespace parameter { namespace aux { 23 | 24 | // Creates a item typelist. 25 | template 26 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 27 | using make_items = ::boost::mp11::mp_if< 28 | ::std::is_same 29 | , ::boost::mp11::mp_identity< ::boost::parameter::void_> 30 | , ::boost::parameter::aux::make_item 31 | >; 32 | #else 33 | struct make_items 34 | : ::boost::mpl::eval_if< 35 | ::boost::is_same 36 | , ::boost::mpl::identity< ::boost::parameter::void_> 37 | , ::boost::parameter::aux::make_item 38 | > 39 | { 40 | }; 41 | #endif 42 | }}} // namespace boost::parameter::aux 43 | 44 | #endif // include guard 45 | 46 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/is_maybe.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin, David Abrahams 2010. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_IS_MAYBE_050329_HPP 7 | #define BOOST_PARAMETER_IS_MAYBE_050329_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | struct maybe_base 12 | { 13 | }; 14 | }}} // namespace boost::parameter::aux 15 | 16 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 17 | #include 18 | 19 | namespace boost { namespace parameter { namespace aux { 20 | 21 | template 22 | using is_maybe = ::std::is_base_of< 23 | ::boost::parameter::aux::maybe_base 24 | , typename ::std::remove_const::type 25 | >; 26 | }}} // namespace boost::parameter::aux 27 | 28 | #else // !defined(BOOST_PARAMETER_CAN_USE_MP11) 29 | #include 30 | #include 31 | #include 32 | #include 33 | 34 | namespace boost { namespace parameter { namespace aux { 35 | 36 | template 37 | struct is_maybe 38 | : ::boost::mpl::if_< 39 | ::boost::is_base_of< 40 | ::boost::parameter::aux::maybe_base 41 | , typename ::boost::remove_const::type 42 | > 43 | , ::boost::mpl::true_ 44 | , ::boost::mpl::false_ 45 | >::type 46 | { 47 | }; 48 | }}} // namespace boost::parameter::aux 49 | 50 | #endif // BOOST_PARAMETER_CAN_USE_MP11 51 | #endif // include guard 52 | 53 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/yesno.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin, David Abrahams 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_YESNO_HPP 7 | #define BOOST_PARAMETER_AUX_YESNO_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | // types used with the "sizeof trick" to capture the results of 12 | // overload resolution at compile-time. 13 | typedef char yes_tag; 14 | typedef char (&no_tag)[2]; 15 | }}} // namespace boost::parameter::aux 16 | 17 | #include 18 | 19 | namespace boost { namespace parameter { namespace aux { 20 | 21 | // mpl::true_ and mpl::false_ are not distinguishable by sizeof(), 22 | // so we pass them through these functions to get a type that is. 23 | ::boost::parameter::aux::yes_tag to_yesno(::boost::mpl::true_); 24 | ::boost::parameter::aux::no_tag to_yesno(::boost::mpl::false_); 25 | }}} // namespace boost::parameter::aux 26 | 27 | #include 28 | 29 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 30 | #include 31 | 32 | namespace boost { namespace parameter { namespace aux { 33 | 34 | // mp11::mp_true and mp11::mp_false are not distinguishable by sizeof(), 35 | // so we pass them through these functions to get a type that is. 36 | ::boost::parameter::aux::yes_tag to_yesno(::boost::mp11::mp_true); 37 | ::boost::parameter::aux::no_tag to_yesno(::boost::mp11::mp_false); 38 | }}} // namespace boost::parameter::aux 39 | 40 | #endif // BOOST_PARAMETER_CAN_USE_MP11 41 | #endif // include guard 42 | 43 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/result_of0.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_RESULT_OF0_DWA2005511_HPP 7 | #define BOOST_PARAMETER_AUX_RESULT_OF0_DWA2005511_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 14 | #include 15 | #include 16 | #else 17 | #include 18 | #include 19 | #endif 20 | 21 | namespace boost { namespace parameter { namespace aux { 22 | 23 | // A metafunction returning the result of invoking 24 | // a nullary function object of the given type. 25 | template 26 | class result_of0 27 | { 28 | #if defined(BOOST_NO_RESULT_OF) 29 | typedef typename F::result_type result_of_F; 30 | #else 31 | typedef typename ::boost::result_of::type result_of_F; 32 | #endif 33 | 34 | public: 35 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 36 | using type = ::boost::mp11::mp_if< 37 | ::std::is_void 38 | #else 39 | typedef typename ::boost::mpl::if_< 40 | ::boost::is_void 41 | #endif 42 | , ::boost::parameter::aux::use_default_tag 43 | , result_of_F 44 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 45 | >; 46 | #else 47 | >::type type; 48 | #endif 49 | }; 50 | }}} // namespace boost::parameter::aux 51 | 52 | #endif // include guard 53 | 54 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/impl/function_forward_match.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_FORWARD_MATCH_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_FUNCTION_FORWARD_MATCH_HPP 8 | 9 | #include 10 | 11 | #if !defined(BOOST_NO_SFINAE) && \ 12 | !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x592)) 13 | 14 | #include 15 | #include 16 | 17 | // Expands to an extra argument that is well-formed 18 | // iff all Args... satisfy the requirements set by params. 19 | #define BOOST_PARAMETER_FUNCTION_FORWARD_MATCH(params, n, prefix) \ 20 | , typename ::boost::parameter::aux::match< \ 21 | params BOOST_PP_ENUM_TRAILING_PARAMS(n, prefix) \ 22 | >::type = params() 23 | /**/ 24 | 25 | #define BOOST_PARAMETER_FUNCTION_FORWARD_MATCH_Z(z, params, n, prefix) \ 26 | , typename ::boost::parameter::aux::match< \ 27 | params BOOST_PP_ENUM_TRAILING_PARAMS_Z(z, n, prefix) \ 28 | >::type = params() 29 | /**/ 30 | 31 | #else // SFINAE/Borland workarounds needed. 32 | 33 | #define BOOST_PARAMETER_FUNCTION_FORWARD_MATCH(params, n, prefix) \ 34 | , params = params() 35 | /**/ 36 | 37 | #define BOOST_PARAMETER_FUNCTION_FORWARD_MATCH_Z(z, params, n, prefix) \ 38 | , params = params() 39 | /**/ 40 | 41 | #endif 42 | #endif // include guard 43 | 44 | -------------------------------------------------------------------------------- /test/macros.cpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | #include 8 | #include 9 | #include "basics.hpp" 10 | 11 | namespace test { 12 | 13 | BOOST_PARAMETER_FUN(int, f, 2, 4, f_parameters) 14 | { 15 | p[test::_tester]( 16 | p[test::_name] 17 | , p[test::_value || boost::bind(&test::value_default)] 18 | , p[test::_index | 999] 19 | ); 20 | 21 | return 1; 22 | } 23 | 24 | BOOST_PARAMETER_NAME(foo) 25 | BOOST_PARAMETER_NAME(bar) 26 | 27 | struct baz_parameters 28 | : boost::parameter::parameters< 29 | boost::parameter::optional 30 | , boost::parameter::optional 31 | > 32 | { 33 | }; 34 | 35 | BOOST_PARAMETER_FUN(int, baz, 0, 2, baz_parameters) 36 | { 37 | return 1; 38 | } 39 | } // namespace test 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | int main() 46 | { 47 | test::f( 48 | test::values( 49 | std::string("foo") 50 | , std::string("bar") 51 | , std::string("baz") 52 | ) 53 | , std::string("foo") 54 | , std::string("bar") 55 | , std::string("baz") 56 | ); 57 | BOOST_TEST_EQ(1, test::baz()); 58 | 59 | int x = 56; 60 | test::f( 61 | test::values(std::string("foo"), 666.222, 56) 62 | , test::_index = boost::ref(x) 63 | , test::_name = std::string("foo") 64 | ); 65 | 66 | return boost::report_errors(); 67 | } 68 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/is_placeholder.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Cromwell D. Enage 2019. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_IS_PLACEHOLDER_HPP 7 | #define BOOST_PARAMETER_AUX_IS_PLACEHOLDER_HPP 8 | 9 | #include 10 | 11 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 12 | #include 13 | #else 14 | #include 15 | #endif 16 | 17 | namespace boost { namespace parameter { namespace aux { 18 | 19 | template 20 | struct is_mpl_placeholder 21 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 22 | : ::boost::mp11::mp_false 23 | #else 24 | : ::boost::mpl::false_ 25 | #endif 26 | { 27 | }; 28 | }}} // namespace boost::parameter::aux 29 | 30 | #include 31 | 32 | namespace boost { namespace parameter { namespace aux { 33 | 34 | template 35 | struct is_mpl_placeholder< ::boost::mpl::arg > 36 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 37 | : ::boost::mp11::mp_true 38 | #else 39 | : ::boost::mpl::true_ 40 | #endif 41 | { 42 | }; 43 | }}} // namespace boost::parameter::aux 44 | 45 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 46 | #include 47 | 48 | namespace boost { namespace parameter { namespace aux { 49 | 50 | template 51 | struct is_mp11_placeholder : ::boost::mp11::mp_false 52 | { 53 | }; 54 | 55 | template < ::std::size_t I> 56 | struct is_mp11_placeholder< ::boost::mp11::mp_arg > 57 | : ::boost::mp11::mp_true 58 | { 59 | }; 60 | }}} // namespace boost::parameter::aux 61 | 62 | #endif // BOOST_PARAMETER_CAN_USE_MP11 63 | #endif // include guard 64 | 65 | -------------------------------------------------------------------------------- /test/literate/building-argumentpacks0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | #include 4 | 5 | BOOST_PARAMETER_NAME(index) 6 | 7 | template 8 | int print_index(ArgumentPack const& args) 9 | { 10 | std::cout << "index = " << args[_index] << std::endl; 11 | return 0; 12 | } 13 | 14 | BOOST_PARAMETER_NAME(name) 15 | 16 | template 17 | int print_name_and_index(ArgumentPack const& args) 18 | { 19 | std::cout << "name = " << args[_name] << "; "; 20 | return print_index(args); 21 | } 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | int main() 30 | { 31 | int x = print_index(_index = 3); // prints "index = 3" 32 | int y = print_name_and_index((_index = 3, _name = "jones")); 33 | boost::parameter::parameters< 34 | boost::parameter::required< 35 | tag::name 36 | , boost::mpl::if_< 37 | boost::is_convertible 38 | , boost::mpl::true_ 39 | , boost::mpl::false_ 40 | > 41 | > 42 | , boost::parameter::optional< 43 | tag::index 44 | , boost::mpl::if_< 45 | boost::is_convertible 46 | , boost::mpl::true_ 47 | , boost::mpl::false_ 48 | > 49 | > 50 | > spec; 51 | char const sam[] = "sam"; 52 | int twelve = 12; 53 | int z0 = print_name_and_index(spec(sam, twelve)); 54 | int z1 = print_name_and_index(spec(_index=12, _name="sam")); 55 | BOOST_TEST(!x); 56 | BOOST_TEST(!y); 57 | BOOST_TEST(!z0); 58 | BOOST_TEST(!z1); 59 | return boost::report_errors(); 60 | } 61 | 62 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/impl/arity_range.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_ARITY_RANGE_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_ARITY_RANGE_HPP 8 | 9 | // Helper macros for BOOST_PARAMETER_ARITY_RANGE. 10 | #define BOOST_PARAMETER_ARITY_RANGE_M_optional(state) state 11 | #define BOOST_PARAMETER_ARITY_RANGE_M_deduced_optional(state) state 12 | 13 | #include 14 | 15 | #define BOOST_PARAMETER_ARITY_RANGE_M_required(state) BOOST_PP_INC(state) 16 | #define BOOST_PARAMETER_ARITY_RANGE_M_deduced_required(state) \ 17 | BOOST_PP_INC(state) 18 | /**/ 19 | 20 | #include 21 | #include 22 | 23 | #define BOOST_PARAMETER_ARITY_RANGE_M(s, state, x) \ 24 | BOOST_PP_CAT( \ 25 | BOOST_PARAMETER_ARITY_RANGE_M_ \ 26 | , BOOST_PARAMETER_FN_ARG_QUALIFIER(x) \ 27 | )(state) 28 | /**/ 29 | 30 | #include 31 | #include 32 | 33 | // Calculates [begin, end) arity range. 34 | #define BOOST_PARAMETER_ARITY_RANGE(args) \ 35 | ( \ 36 | BOOST_PP_SEQ_FOLD_LEFT(BOOST_PARAMETER_ARITY_RANGE_M, 0, args) \ 37 | , BOOST_PP_INC(BOOST_PP_SEQ_SIZE(args)) \ 38 | ) 39 | /**/ 40 | 41 | #endif // include guard 42 | 43 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pp_impl/match.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Copyright Cromwell D. Enage 2017. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_PARAMETER_AUX_PP_IMPL_MATCH_HPP 8 | #define BOOST_PARAMETER_AUX_PP_IMPL_MATCH_HPP 9 | 10 | #include 11 | 12 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 13 | 14 | namespace boost { namespace parameter { namespace aux { 15 | 16 | // Recast the ParameterSpec's nested match metafunction 17 | // as a free metafunction. 18 | // 19 | // No more limits set by BOOST_PARAMETER_MAX_ARITY. -- Cromwell D. Enage 20 | template 21 | struct match : Parameters::BOOST_NESTED_TEMPLATE match 22 | { 23 | }; 24 | }}} // namespace boost::parameter::aux 25 | 26 | #else 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | 33 | namespace boost { namespace parameter { namespace aux { 34 | 35 | // Recast the ParameterSpec's nested match metafunction 36 | // as a free metafunction. 37 | template < 38 | typename Parameters 39 | BOOST_PP_ENUM_TRAILING_BINARY_PARAMS( 40 | BOOST_PARAMETER_MAX_ARITY 41 | , typename A 42 | , = ::boost::parameter::void_ BOOST_PP_INTERCEPT 43 | ) 44 | > 45 | struct match 46 | : Parameters::BOOST_NESTED_TEMPLATE match< 47 | BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, A) 48 | > 49 | { 50 | }; 51 | }}} // namespace boost::parameter::aux 52 | 53 | #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING 54 | #endif // include guard 55 | 56 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/make_deduced_items.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_MAKE_DEDUCED_ITEMS_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_MAKE_DEDUCED_ITEMS_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 15 | #include 16 | #include 17 | #else 18 | #include 19 | #include 20 | #include 21 | #endif 22 | 23 | namespace boost { namespace parameter { namespace aux { 24 | 25 | template 26 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 27 | using make_deduced_items = ::boost::mp11::mp_if< 28 | ::std::is_same 29 | , ::boost::mp11::mp_identity< ::boost::parameter::void_> 30 | , ::boost::mp11::mp_if< 31 | ::boost::parameter::aux::is_deduced 32 | , ::boost::parameter::aux::make_deduced_item 33 | , Tail 34 | > 35 | >; 36 | #else 37 | struct make_deduced_items 38 | : ::boost::mpl::eval_if< 39 | ::boost::is_same 40 | , ::boost::mpl::identity< ::boost::parameter::void_> 41 | , ::boost::mpl::eval_if< 42 | ::boost::parameter::aux::is_deduced 43 | , ::boost::parameter::aux::make_deduced_item 44 | , Tail 45 | > 46 | > 47 | { 48 | }; 49 | #endif // BOOST_PARAMETER_CAN_USE_MP11 50 | }}} // namespace boost::parameter::aux 51 | 52 | #endif // include guard 53 | 54 | -------------------------------------------------------------------------------- /include/boost/parameter/match.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams 2005. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_MATCH_DWA2005714_HPP 7 | #define BOOST_PARAMETER_MATCH_DWA2005714_HPP 8 | 9 | #include 10 | 11 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | #define BOOST_PARAMETER_MATCH_DEFAULTS(ArgTypes) \ 19 | BOOST_PP_ENUM_TRAILING_PARAMS( \ 20 | BOOST_PP_SUB( \ 21 | BOOST_PARAMETER_MAX_ARITY \ 22 | , BOOST_PP_SEQ_SIZE(ArgTypes) \ 23 | ) \ 24 | , ::boost::parameter::void_ BOOST_PP_INTERCEPT \ 25 | ) 26 | /**/ 27 | #else 28 | #define BOOST_PARAMETER_MATCH_DEFAULTS(ArgTypes) 29 | #endif 30 | 31 | #include 32 | 33 | // 34 | // Generates, e.g. 35 | // 36 | // typename dfs_params::match::type name = dfs_params() 37 | // 38 | // with workarounds for Borland compatibility. 39 | // 40 | #define BOOST_PARAMETER_MATCH(ParameterSpec, ArgTypes, name) \ 41 | typename ParameterSpec::match< \ 42 | BOOST_PARAMETER_SEQ_ENUM(ArgTypes) \ 43 | BOOST_PARAMETER_MATCH_DEFAULTS(ArgTypes) \ 44 | >::type name = ParameterSpec() 45 | /**/ 46 | 47 | #endif // include guard 48 | 49 | -------------------------------------------------------------------------------- /include/boost/parameter/required.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_REQUIRED_HPP 7 | #define BOOST_PARAMETER_REQUIRED_HPP 8 | 9 | #include 10 | 11 | namespace boost { namespace parameter { 12 | 13 | // This metafunction can be used to describe the treatment of particular 14 | // named parameters for the purposes of overload elimination with SFINAE, 15 | // by placing specializations in the parameters<...> list. In order for 16 | // a treated function to participate in overload resolution: 17 | // 18 | // - all keyword tags wrapped in required<...> must have a matching 19 | // actual argument 20 | // 21 | // - The actual argument type matched by every keyword tag 22 | // associated with a predicate must satisfy that predicate 23 | template < 24 | typename Tag 25 | , typename Predicate = ::boost::parameter::aux::use_default 26 | > 27 | struct required 28 | { 29 | typedef Tag key_type; 30 | typedef Predicate predicate; 31 | }; 32 | }} 33 | 34 | #include 35 | 36 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 37 | #include 38 | #else 39 | #include 40 | #endif 41 | 42 | namespace boost { namespace parameter { namespace aux { 43 | 44 | template 45 | struct is_required 46 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 47 | : ::boost::mp11::mp_false 48 | #else 49 | : ::boost::mpl::false_ 50 | #endif 51 | { 52 | }; 53 | 54 | template 55 | struct is_required< ::boost::parameter::required > 56 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 57 | : ::boost::mp11::mp_true 58 | #else 59 | : ::boost::mpl::true_ 60 | #endif 61 | { 62 | }; 63 | }}} // namespace boost::parameter::aux 64 | 65 | #endif // include guard 66 | 67 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/tag_deduced.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_TAG_DEDUCED_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_TAG_DEDUCED_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 14 | #include 15 | #include 16 | #else 17 | #include 18 | #include 19 | #endif 20 | 21 | namespace boost { namespace parameter { namespace aux { 22 | 23 | // Tags a deduced argument Arg with the keyword tag of Spec using TagFn. 24 | // Returns the tagged argument and the mpl::set<> UsedArgs with the 25 | // tag of Spec inserted. 26 | template 27 | struct tag_deduced 28 | { 29 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 30 | using type = ::boost::mp11::mp_list< 31 | ::boost::mp11::mp_apply_q< 32 | TagFn 33 | , ::boost::mp11::mp_list< 34 | typename ::boost::parameter::aux::tag_type::type 35 | , Arg 36 | > 37 | > 38 | #else 39 | typedef ::boost::mpl::pair< 40 | typename ::boost::mpl::apply_wrap2< 41 | TagFn 42 | , typename ::boost::parameter::aux::tag_type::type 43 | , Arg 44 | >::type 45 | #endif // BOOST_PARAMETER_CAN_USE_MP11 46 | , typename ::boost::parameter::aux::insert_< 47 | UsedArgs 48 | , typename ::boost::parameter::aux::tag_type::type 49 | >::type 50 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 51 | >; 52 | #else 53 | > type; 54 | #endif 55 | }; 56 | }}} // namespace boost::parameter::aux 57 | 58 | #endif // include guard 59 | 60 | -------------------------------------------------------------------------------- /include/boost/parameter/optional.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_OPTIONAL_HPP 7 | #define BOOST_PARAMETER_OPTIONAL_HPP 8 | 9 | #include 10 | 11 | namespace boost { namespace parameter { 12 | 13 | // This metafunction can be used to describe the treatment of particular 14 | // named parameters for the purposes of overload elimination with SFINAE, 15 | // by placing specializations in the parameters<...> list. In order for 16 | // a treated function to participate in overload resolution: 17 | // 18 | // - The actual argument type matched by every keyword tag 19 | // associated with a predicate must satisfy that predicate 20 | // 21 | // - If a keyword k is specified without an optional<...> or 22 | // required<...> wrapper, it is treated as though 23 | // optional were specified. 24 | template < 25 | typename Tag 26 | , typename Predicate = ::boost::parameter::aux::use_default 27 | > 28 | struct optional 29 | { 30 | typedef Tag key_type; 31 | typedef Predicate predicate; 32 | }; 33 | }} 34 | 35 | #include 36 | 37 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 38 | #include 39 | #else 40 | #include 41 | #endif 42 | 43 | namespace boost { namespace parameter { namespace aux { 44 | 45 | template 46 | struct is_optional 47 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 48 | : ::boost::mp11::mp_false 49 | #else 50 | : ::boost::mpl::false_ 51 | #endif 52 | { 53 | }; 54 | 55 | template 56 | struct is_optional< ::boost::parameter::optional > 57 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 58 | : ::boost::mp11::mp_true 59 | #else 60 | : ::boost::mpl::true_ 61 | #endif 62 | { 63 | }; 64 | }}} // namespace boost::parameter::aux 65 | 66 | #endif // include guard 67 | 68 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/convert_binary_seq.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Cromwell D. Enage 2013. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_CONVERT_BINARY_SEQ_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_CONVERT_BINARY_SEQ_HPP 8 | 9 | #include 10 | #include 11 | 12 | #define BOOST_PARAMETER_AUX_PP_AUGMENT_BINARY_SEQ_INDEX_FOLD_OP(s, seq, idx) \ 13 | BOOST_PP_SEQ_PUSH_BACK(seq, (idx, BOOST_PP_SEQ_SIZE(seq))) 14 | /**/ 15 | 16 | #include 17 | #include 18 | #include 19 | 20 | #define BOOST_PARAMETER_AUX_PP_CONVERT_BINARY_SEQ_FOLD_OP(s, seq, elem) \ 21 | ( \ 22 | BOOST_PP_SEQ_PUSH_BACK( \ 23 | BOOST_PP_SEQ_ELEM(0, seq) \ 24 | , BOOST_PP_IIF( \ 25 | BOOST_PP_TUPLE_ELEM(2, 0, elem) \ 26 | , BOOST_PP_SEQ_ELEM(2, seq) \ 27 | , BOOST_PP_SEQ_ELEM(1, seq) \ 28 | )(BOOST_PP_TUPLE_ELEM(2, 1, elem), BOOST_PP_SEQ_ELEM(3, seq)) \ 29 | ) \ 30 | )(BOOST_PP_SEQ_ELEM(1, seq))(BOOST_PP_SEQ_ELEM(2, seq)) \ 31 | (BOOST_PP_SEQ_ELEM(3, seq)) 32 | /**/ 33 | 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #define BOOST_PARAMETER_AUX_PP_CONVERT_BINARY_SEQ(seq, macro0, macro1, data) \ 40 | BOOST_PARAMETER_SEQ_ENUM( \ 41 | BOOST_PP_SEQ_ELEM( \ 42 | 0 \ 43 | , BOOST_PP_SEQ_FOLD_LEFT( \ 44 | BOOST_PARAMETER_AUX_PP_CONVERT_BINARY_SEQ_FOLD_OP \ 45 | , (BOOST_PP_SEQ_NIL)(macro0)(macro1)(data) \ 46 | , BOOST_PP_SEQ_FOLD_LEFT( \ 47 | BOOST_PARAMETER_AUX_PP_AUGMENT_BINARY_SEQ_INDEX_FOLD_OP \ 48 | , BOOST_PP_EMPTY() \ 49 | , seq \ 50 | ) \ 51 | ) \ 52 | ) \ 53 | ) 54 | /**/ 55 | 56 | #endif // include guard 57 | 58 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/tag_keyword_arg_ref.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_TAG_KEYWORD_ARG_REF_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_TAG_KEYWORD_ARG_REF_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | namespace boost { namespace parameter { namespace aux { 14 | 15 | template < 16 | typename Keyword 17 | , typename ActualArg 18 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) 19 | , typename = typename ::boost::parameter::aux 20 | ::is_cv_reference_wrapper::type 21 | #endif 22 | > 23 | struct tag_ref 24 | { 25 | typedef ::boost::parameter::aux::tagged_argument< 26 | Keyword 27 | , typename ::boost::parameter::aux 28 | ::unwrap_cv_reference::type 29 | > type; 30 | }; 31 | }}} // namespace boost::parameter::aux_ 32 | 33 | #if BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) 34 | 35 | #include 36 | 37 | namespace boost { namespace parameter { namespace aux { 38 | 39 | template 40 | struct tag_ref 41 | { 42 | typedef ::boost::parameter::aux 43 | ::tagged_argument type; 44 | }; 45 | }}} // namespace boost::parameter::aux_ 46 | 47 | #endif // Borland workarounds needed. 48 | 49 | namespace boost { namespace parameter { namespace aux { 50 | 51 | struct tag_keyword_arg_ref 52 | { 53 | template 54 | struct apply 55 | { 56 | typedef typename ::boost::parameter::aux::tag_ref::type type; 57 | }; 58 | 59 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 60 | template 61 | using fn = typename ::boost::parameter::aux::tag_ref::type; 62 | #endif 63 | }; 64 | }}} // namespace boost::parameter::aux 65 | 66 | #endif // include guard 67 | 68 | -------------------------------------------------------------------------------- /test/timer.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Andrey Semashev 2023. 2 | // 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | // This file is a copy of boost/timer.hpp from Boost.Timer v1, which 8 | // was deprecated and slated for removal. We are not using Boost.Timer v2 9 | // components to avoid having to link with its binary. 10 | // 11 | // See http://www.boost.org/libs/timer for documentation. 12 | 13 | #ifndef BOOST_PARAMETER_TEST_TIMER_HPP 14 | #define BOOST_PARAMETER_TEST_TIMER_HPP 15 | 16 | #include 17 | #include 18 | 19 | namespace test { 20 | 21 | // timer -------------------------------------------------------------------// 22 | 23 | // A timer object measures elapsed time. 24 | 25 | // It is recommended that implementations measure wall clock rather than CPU 26 | // time since the intended use is performance measurement on systems where 27 | // total elapsed time is more important than just process or CPU time. 28 | 29 | // Warnings: The maximum measurable elapsed time may well be only 596.5+ hours 30 | // due to implementation limitations. The accuracy of timings depends on the 31 | // accuracy of timing information provided by the underlying platform, and 32 | // this varies a great deal from platform to platform. 33 | 34 | class timer 35 | { 36 | public: 37 | timer() { _start_time = std::clock(); } // postcondition: elapsed()==0 38 | void restart() { _start_time = std::clock(); } // post: elapsed()==0 39 | double elapsed() const // return elapsed time in seconds 40 | { return double(std::clock() - _start_time) / CLOCKS_PER_SEC; } 41 | 42 | double elapsed_max() const // return estimated maximum value for elapsed() 43 | // Portability warning: elapsed_max() may return too high a value on systems 44 | // where std::clock_t overflows or resets at surprising values. 45 | { 46 | return (double((std::numeric_limits::max)()) 47 | - double(_start_time)) / double(CLOCKS_PER_SEC); 48 | } 49 | 50 | double elapsed_min() const // return minimum value for elapsed() 51 | { return double(1)/double(CLOCKS_PER_SEC); } 52 | 53 | private: 54 | std::clock_t _start_time; 55 | }; // timer 56 | 57 | } // namespace test 58 | 59 | #endif // BOOST_PARAMETER_TEST_TIMER_HPP 60 | -------------------------------------------------------------------------------- /test/literate/deduced-parameters0.cpp: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | 4 | BOOST_PARAMETER_NAME(name) 5 | BOOST_PARAMETER_NAME(func) 6 | BOOST_PARAMETER_NAME(docstring) 7 | BOOST_PARAMETER_NAME(keywords) 8 | BOOST_PARAMETER_NAME(policies) 9 | 10 | struct default_call_policies 11 | { 12 | }; 13 | 14 | struct no_keywords 15 | { 16 | }; 17 | 18 | struct keywords 19 | { 20 | }; 21 | 22 | #include 23 | 24 | template 25 | struct is_keyword_expression 26 | : boost::mpl::false_ 27 | { 28 | }; 29 | 30 | template <> 31 | struct is_keyword_expression 32 | : boost::mpl::true_ 33 | { 34 | }; 35 | 36 | default_call_policies some_policies; 37 | 38 | void f() 39 | { 40 | } 41 | 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | char const*& blank_char_ptr() 48 | { 49 | static char const* larr = ""; 50 | return larr; 51 | } 52 | 53 | BOOST_PARAMETER_FUNCTION( 54 | (bool), def, tag, 55 | (required (name,(char const*)) (func,*) ) // nondeduced 56 | (deduced 57 | (optional 58 | (docstring, (char const*), blank_char_ptr()) 59 | (keywords 60 | // see 5 61 | , *(is_keyword_expression) 62 | , no_keywords() 63 | ) 64 | (policies 65 | , *( 66 | boost::mpl::eval_if< 67 | boost::is_convertible 68 | , boost::mpl::false_ 69 | , boost::mpl::if_< 70 | // see 5 71 | is_keyword_expression 72 | , boost::mpl::false_ 73 | , boost::mpl::true_ 74 | > 75 | > 76 | ) 77 | , default_call_policies() 78 | ) 79 | ) 80 | ) 81 | ) 82 | { 83 | return true; 84 | } 85 | 86 | #include 87 | 88 | int main() 89 | { 90 | char const* f_name = "f"; 91 | def(f_name, &f, some_policies, "Documentation for f"); 92 | def(f_name, &f, "Documentation for f", some_policies); 93 | def( 94 | f_name 95 | , &f 96 | , _policies = some_policies 97 | , "Documentation for f" 98 | ); 99 | return boost::report_errors(); 100 | } 101 | 102 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Boost.Parameter 2 | 3 | Boost.Parameter, part of collection of the [Boost C++ Libraries](https://github.com/boostorg), is a header-only library that implements named parameters for functions and templates in C++. 4 | 5 | ### Directories 6 | 7 | * **doc** - Documentation sources 8 | * **include** - Interface headers of Boost.Parameter 9 | * **test** - Boost.Parameter unit tests 10 | 11 | ### More information 12 | 13 | * [Documentation](https://www.boost.org/libs/parameter) 14 | * [Report bugs](https://github.com/boostorg/parameter/issues/new). Be sure to mention Boost version, platform and compiler you're using. A small compilable code sample to reproduce the problem is always good as well. 15 | * Submit your patches as [pull requests](https://github.com/boostorg/parameter/compare) against **develop** branch. Note that by submitting patches you agree to license your modifications under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). 16 | 17 | ### Build status 18 | 19 | Branch | GitHub Actions | AppVeyor | Test Matrix | Dependencies | 20 | :-------------: | -------------- | -------- | ----------- | ------------ | 21 | [`master`](https://github.com/boostorg/parameter/tree/master) | [![GitHub Actions](https://github.com/boostorg/parameter/actions/workflows/ci.yml/badge.svg?branch=master)](https://github.com/boostorg/parameter/actions?query=branch%3Amaster) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/e9iptg55otiv040a/branch/master?svg=true)](https://ci.appveyor.com/project/Lastique/parameter/branch/master) | [![Tests](https://img.shields.io/badge/matrix-master-brightgreen.svg)](https://regression.boost.io/master/developer/parameter.html) | [![Dependencies](https://img.shields.io/badge/deps-master-brightgreen.svg)](https://pdimov.github.io/boostdep-report/master/parameter.html) 22 | [`develop`](https://github.com/boostorg/parameter/tree/develop) | [![GitHub Actions](https://github.com/boostorg/parameter/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/boostorg/parameter/actions?query=branch%3Adevelop) | [![AppVeyor](https://ci.appveyor.com/api/projects/status/e9iptg55otiv040a/branch/develop?svg=true)](https://ci.appveyor.com/project/Lastique/parameter/branch/develop) | [![Tests](https://img.shields.io/badge/matrix-develop-brightgreen.svg)](https://regression.boost.io/develop/developer/parameter.html) | [![Dependencies](https://img.shields.io/badge/deps-develop-brightgreen.svg)](https://pdimov.github.io/boostdep-report/develop/parameter.html) 23 | 24 | ### License 25 | 26 | Distributed under the [Boost Software License, Version 1.0](https://www.boost.org/LICENSE_1_0.txt). 27 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/tag_type.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_TAG_TYPE_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_TAG_TYPE_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | // helper for tag_type<...>, below. 12 | template 13 | struct get_tag_type0 14 | { 15 | typedef typename T::key_type type; 16 | }; 17 | }}} // namespace boost::parameter::aux 18 | 19 | #include 20 | #include 21 | 22 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | namespace boost { namespace parameter { namespace aux { 29 | 30 | template 31 | struct get_tag_type 32 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 33 | : ::boost::mp11::mp_if< 34 | #else 35 | : ::boost::mpl::eval_if< 36 | #endif 37 | ::boost::parameter::aux::is_deduced0 38 | , ::boost::parameter::aux::get_tag_type0 39 | , ::boost::parameter::aux::get_tag_type0 40 | > 41 | { 42 | }; 43 | }}} // namespace boost::parameter::aux 44 | 45 | #include 46 | #include 47 | 48 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 49 | #include 50 | 51 | namespace boost { namespace parameter { namespace aux { 52 | 53 | template 54 | using tag_type = ::boost::mp11::mp_if< 55 | ::boost::mp11::mp_if< 56 | ::boost::parameter::aux::is_optional 57 | , ::boost::mp11::mp_true 58 | , ::boost::parameter::aux::is_required 59 | > 60 | , ::boost::parameter::aux::get_tag_type 61 | , ::boost::mp11::mp_identity 62 | >; 63 | }}} // namespace boost::parameter::aux 64 | 65 | #else // !defined(BOOST_PARAMETER_CAN_USE_MP11) 66 | #include 67 | #include 68 | #include 69 | 70 | namespace boost { namespace parameter { namespace aux { 71 | 72 | template 73 | struct tag_type 74 | : ::boost::mpl::eval_if< 75 | typename ::boost::mpl::if_< 76 | ::boost::parameter::aux::is_optional 77 | , ::boost::mpl::true_ 78 | , ::boost::parameter::aux::is_required 79 | >::type 80 | , ::boost::parameter::aux::get_tag_type 81 | , ::boost::mpl::identity 82 | > 83 | { 84 | }; 85 | }}} // namespace boost::parameter::aux 86 | 87 | #endif // BOOST_PARAMETER_CAN_USE_MP11 88 | #endif // include guard 89 | 90 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pack/predicate.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PACK_PREDICATE_HPP 7 | #define BOOST_PARAMETER_AUX_PACK_PREDICATE_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | // helper for get_predicate<...>, below 12 | template 13 | struct get_predicate_or_default 14 | { 15 | typedef T type; 16 | }; 17 | 18 | // helper for predicate<...>, below 19 | template 20 | struct get_predicate 21 | : ::boost::parameter::aux 22 | ::get_predicate_or_default 23 | { 24 | }; 25 | }}} // namespace boost::parameter::aux 26 | 27 | #include 28 | #include 29 | 30 | namespace boost { namespace parameter { namespace aux { 31 | 32 | template <> 33 | struct get_predicate_or_default< ::boost::parameter::aux::use_default> 34 | { 35 | typedef ::boost::parameter::aux::always_true_predicate type; 36 | }; 37 | }}} // namespace boost::parameter::aux 38 | 39 | #include 40 | #include 41 | #include 42 | 43 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 44 | #include 45 | #include 46 | #else 47 | #include 48 | #include 49 | #include 50 | #include 51 | #endif 52 | 53 | namespace boost { namespace parameter { namespace aux { 54 | 55 | template 56 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 57 | using predicate = ::boost::mp11::mp_if< 58 | ::boost::mp11::mp_if< 59 | ::boost::parameter::aux::is_optional 60 | , ::boost::mp11::mp_true 61 | , ::boost::parameter::aux::is_required 62 | > 63 | , ::boost::parameter::aux::get_predicate 64 | , ::boost::mp11::mp_identity< 65 | ::boost::parameter::aux::always_true_predicate 66 | > 67 | >; 68 | #else 69 | struct predicate 70 | : ::boost::mpl::eval_if< 71 | typename ::boost::mpl::if_< 72 | ::boost::parameter::aux::is_optional 73 | , ::boost::mpl::true_ 74 | , ::boost::parameter::aux::is_required 75 | >::type 76 | , ::boost::parameter::aux::get_predicate 77 | , ::boost::mpl::identity< 78 | ::boost::parameter::aux::always_true_predicate 79 | > 80 | > 81 | { 82 | }; 83 | #endif // BOOST_PARAMETER_CAN_USE_MP11 84 | }}} // namespace boost::parameter::aux 85 | 86 | #endif // include guard 87 | 88 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/binary_seq_to_args.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Cromwell D. Enage 2017. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_BINARY_SEQ_TO_ARGS_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_BINARY_SEQ_TO_ARGS_HPP 8 | 9 | #include 10 | #include 11 | 12 | #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0_1(n, prefix_seq) \ 13 | BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, prefix_seq), n) const& 14 | /**/ 15 | 16 | #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1_1(n, prefix_seq) \ 17 | BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(0, prefix_seq), n)& 18 | /**/ 19 | 20 | #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0_2(n, prefix_seq) \ 21 | BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0_1(n, prefix_seq) \ 22 | BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1, prefix_seq), n) 23 | /**/ 24 | 25 | #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1_2(n, prefix_seq) \ 26 | BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1_1(n, prefix_seq) \ 27 | BOOST_PP_CAT(BOOST_PP_SEQ_ELEM(1, prefix_seq), n) 28 | /**/ 29 | 30 | #include 31 | 32 | #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0(prefix_seq) \ 33 | BOOST_PP_CAT( \ 34 | BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0_ \ 35 | , BOOST_PP_SEQ_SIZE(prefix_seq) \ 36 | ) 37 | /**/ 38 | 39 | #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1(prefix_seq) \ 40 | BOOST_PP_CAT( \ 41 | BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1_ \ 42 | , BOOST_PP_SEQ_SIZE(prefix_seq) \ 43 | ) 44 | /**/ 45 | 46 | #include 47 | 48 | // This macro converts the specified Boost.Preprocessor sequence of 1s and 0s 49 | // into a formal function parameter list. 50 | // 51 | // Example: 52 | // BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARGS((1)(0)(1)(0), (P)(p)) 53 | // expands to 54 | // P0 & p0, P1 const& p1, P2 & p2, P3 const& p3 55 | #define BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARGS(binary_seq, prefix_seq) \ 56 | BOOST_PARAMETER_AUX_PP_CONVERT_BINARY_SEQ( \ 57 | binary_seq \ 58 | , BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_0(prefix_seq) \ 59 | , BOOST_PARAMETER_AUX_PP_BINARY_SEQ_TO_ARG_1(prefix_seq) \ 60 | , prefix_seq \ 61 | ) 62 | /**/ 63 | 64 | #endif // include guard 65 | 66 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/template_keyword.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Copyright Cromwell D. Enage 2017. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_PARAMETER_TEMPLATE_KEYWORD_060203_HPP 8 | #define BOOST_PARAMETER_TEMPLATE_KEYWORD_060203_HPP 9 | 10 | namespace boost { namespace parameter { namespace aux { 11 | 12 | struct template_keyword_base 13 | { 14 | }; 15 | }}} // namespace boost::parameter::aux 16 | 17 | #include 18 | 19 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 20 | #include 21 | 22 | namespace boost { namespace parameter { namespace aux { 23 | 24 | template 25 | using is_template_keyword = ::std::is_base_of< 26 | ::boost::parameter::aux::template_keyword_base 27 | , typename ::std::remove_const< 28 | typename ::std::remove_reference::type 29 | >::type 30 | >; 31 | }}} // namespace boost::parameter::aux 32 | 33 | #else // !defined(BOOST_PARAMETER_CAN_USE_MP11) 34 | #include 35 | #include 36 | #include 37 | 38 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 39 | #include 40 | #include 41 | #else 42 | #include 43 | #include 44 | #endif 45 | 46 | namespace boost { namespace parameter { namespace aux { 47 | 48 | #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 49 | template 50 | struct is_template_keyword_aux 51 | : ::boost::mpl::if_< 52 | ::boost::is_convertible< 53 | T* 54 | , ::boost::parameter::aux::template_keyword_base const* 55 | > 56 | , ::boost::mpl::true_ 57 | , ::boost::mpl::false_ 58 | >::type 59 | { 60 | }; 61 | #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING 62 | 63 | template 64 | struct is_template_keyword 65 | : ::boost::mpl::if_< 66 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 67 | // Cannot use is_convertible<> to check if T is derived from 68 | // template_keyword_base. -- Cromwell D. Enage 69 | ::boost::is_base_of< 70 | ::boost::parameter::aux::template_keyword_base 71 | , typename ::boost::remove_const< 72 | typename ::boost::remove_reference::type 73 | >::type 74 | > 75 | , ::boost::mpl::true_ 76 | , ::boost::mpl::false_ 77 | #else 78 | ::boost::is_lvalue_reference 79 | , ::boost::mpl::false_ 80 | , ::boost::parameter::aux::is_template_keyword_aux 81 | #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING 82 | >::type 83 | { 84 | }; 85 | }}} // namespace boost::parameter::aux 86 | 87 | #endif // BOOST_PARAMETER_CAN_USE_MP11 88 | #endif // include guard 89 | 90 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/name.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_NAME_HPP 7 | #define BOOST_PARAMETER_AUX_NAME_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | struct name_tag_base 12 | { 13 | }; 14 | 15 | template 16 | struct name_tag 17 | { 18 | }; 19 | }}} // namespace boost::parameter::aux 20 | 21 | #include 22 | 23 | namespace boost { namespace parameter { namespace aux { 24 | 25 | template 26 | struct is_name_tag : ::boost::mpl::false_ 27 | { 28 | }; 29 | }}} // namespace boost::parameter::aux 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #if !defined(BOOST_NO_SFINAE) && \ 37 | !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x592)) 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | 44 | namespace boost { namespace mpl { 45 | 46 | template 47 | struct lambda< 48 | T 49 | , typename ::boost::enable_if< 50 | ::boost::parameter::aux::is_name_tag 51 | , ::boost::parameter::aux::lambda_tag 52 | >::type 53 | > 54 | { 55 | typedef ::boost::mpl::true_ is_le; 56 | typedef ::boost::mpl::bind3< 57 | ::boost::mpl::quote3< ::boost::parameter::value_type> 58 | , ::boost::mpl::arg<2> 59 | , T 60 | , void 61 | > result_; 62 | typedef result_ type; 63 | }; 64 | }} // namespace boost::mpl 65 | 66 | #endif // SFINAE enabled, not Borland. 67 | 68 | #include 69 | 70 | #define BOOST_PARAMETER_TAG_PLACEHOLDER_TYPE(tag) \ 71 | ::boost::parameter::value_type< \ 72 | ::boost::mpl::_2,tag,::boost::parameter::void_ \ 73 | > 74 | /**/ 75 | 76 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 77 | #define BOOST_PARAMETER_TAG_MP11_PLACEHOLDER_VALUE(name, tag) \ 78 | template \ 79 | using name = typename ::boost::parameter \ 80 | ::value_type::type 81 | /**/ 82 | 83 | #include 84 | 85 | #define BOOST_PARAMETER_TAG_MP11_PLACEHOLDER_BINDING(name, tag) \ 86 | template \ 87 | using name = typename ::boost::parameter \ 88 | ::binding::type 89 | /**/ 90 | 91 | #endif // BOOST_PARAMETER_CAN_USE_MP11 92 | #endif // include guard 93 | 94 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/inc_binary_seq.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Cromwell D. Enage 2013. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_INC_BINARY_SEQ_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_INC_BINARY_SEQ_HPP 8 | 9 | #include 10 | 11 | // This macro keeps the rest of the sequence if carry == 0. 12 | #define BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_0(seq, element) \ 13 | (BOOST_PP_SEQ_PUSH_BACK(seq, element), 0) 14 | /**/ 15 | 16 | #include 17 | 18 | // This macro updates the rest of the sequence if carry == 1. 19 | #define BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_1(seq, element) \ 20 | (BOOST_PP_SEQ_PUSH_BACK(seq, BOOST_PP_IIF(element, 0, 1)), element) 21 | /**/ 22 | 23 | #include 24 | #include 25 | 26 | // This macro maintains a tuple (seq, carry), where seq is the intermediate 27 | // result and carry is a flag that will unset upon finding an element == 0. 28 | #define BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_OP(s, result_tuple, element) \ 29 | BOOST_PP_CAT( \ 30 | BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_ \ 31 | , BOOST_PP_TUPLE_ELEM(2, 1, result_tuple) \ 32 | )(BOOST_PP_TUPLE_ELEM(2, 0, result_tuple), element) 33 | /**/ 34 | 35 | // This macro keeps the sequence at its original length if carry == 0. 36 | #define BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_IMPL_0(seq) seq 37 | /**/ 38 | 39 | // This macro appends a zero to seq if carry == 1. 40 | #define BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_IMPL_1(seq) \ 41 | BOOST_PP_SEQ_PUSH_BACK(seq, 0) 42 | /**/ 43 | 44 | // This macro takes in the tuple (seq, carry), with carry indicating whether 45 | // or not seq originally contained all 1s. If so, then seq now contains all 46 | // 0s, and this macro pushes an extra 0 before expanding to the new sequence. 47 | // Otherwise, this macro expands to seq as is. 48 | #define BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_IMPL(seq_and_carry) \ 49 | BOOST_PP_CAT( \ 50 | BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_IMPL_ \ 51 | , BOOST_PP_TUPLE_ELEM(2, 1, seq_and_carry) \ 52 | )(BOOST_PP_TUPLE_ELEM(2, 0, seq_and_carry)) 53 | /**/ 54 | 55 | #include 56 | #include 57 | 58 | // This macro treats the specified sequence of 1s and 0s like a binary number 59 | // in reverse and expands to a sequence representing the next value up. 60 | // However, if the input sequence contains all 1s, then the output sequence 61 | // will contain one more element but all 0s. 62 | // 63 | // Examples: 64 | // seq = (1)(0)(1)(0) --> return (0)(1)(1)(0) 65 | // seq = (1)(1)(1)(0) --> return (0)(0)(0)(1) 66 | // seq = (1)(1)(1)(1) --> return (0)(0)(0)(0)(0) 67 | #define BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ(seq) \ 68 | BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_IMPL( \ 69 | BOOST_PP_SEQ_FOLD_LEFT( \ 70 | BOOST_PARAMETER_AUX_PP_INC_BINARY_SEQ_OP \ 71 | , (BOOST_PP_SEQ_NIL, 1) \ 72 | , seq \ 73 | ) \ 74 | ) 75 | /**/ 76 | 77 | #endif // include guard 78 | 79 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/qualifier.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Copyright Cromwell D. Enage 2017. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_QUALIFIER_HPP 8 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_QUALIFIER_HPP 9 | 10 | #define BOOST_PARAMETER_QUALIFIER_EAT_in(x) 11 | #define BOOST_PARAMETER_QUALIFIER_EAT_out(x) 12 | #define BOOST_PARAMETER_QUALIFIER_EAT_in_out(x) 13 | #define BOOST_PARAMETER_QUALIFIER_EAT_consume(x) 14 | #define BOOST_PARAMETER_QUALIFIER_EAT_move_from(x) 15 | #define BOOST_PARAMETER_QUALIFIER_EAT_forward(x) 16 | 17 | #define BOOST_PARAMETER_GET_QUALIFIER_in(x) in_reference 18 | #define BOOST_PARAMETER_GET_QUALIFIER_out(x) out_reference 19 | #define BOOST_PARAMETER_GET_QUALIFIER_in_out(x) in_out_reference 20 | #define BOOST_PARAMETER_GET_QUALIFIER_consume(x) consume_reference 21 | #define BOOST_PARAMETER_GET_QUALIFIER_move_from(x) move_from_reference 22 | #define BOOST_PARAMETER_GET_QUALIFIER_forward(x) forward_reference 23 | 24 | #define BOOST_PARAMETER_STRIP_QUALIFIER_in(x) x 25 | #define BOOST_PARAMETER_STRIP_QUALIFIER_out(x) x 26 | #define BOOST_PARAMETER_STRIP_QUALIFIER_in_out(x) x 27 | #define BOOST_PARAMETER_STRIP_QUALIFIER_consume(x) x 28 | #define BOOST_PARAMETER_STRIP_QUALIFIER_move_from(x) x 29 | #define BOOST_PARAMETER_STRIP_QUALIFIER_forward(x) x 30 | 31 | #include 32 | 33 | #define BOOST_PARAMETER_GET_QUALIFIER_GET(x) \ 34 | BOOST_PP_CAT(BOOST_PARAMETER_GET_QUALIFIER_, x) 35 | /**/ 36 | 37 | #define BOOST_PARAMETER_GET_UNQUALIFIED(x) \ 38 | BOOST_PP_CAT(BOOST_PARAMETER_STRIP_QUALIFIER_, x) 39 | /**/ 40 | 41 | #include 42 | 43 | // Expands to 1 if x is either "in(k)", "out(k)", "in_out(k)", "consume(k)", 44 | // "move_from(k)", or "forward(k)"; expands to 0 otherwise. 45 | #define BOOST_PARAMETER_IS_QUALIFIER(x) \ 46 | BOOST_PP_IS_EMPTY(BOOST_PP_CAT(BOOST_PARAMETER_QUALIFIER_EAT_, x)) 47 | /**/ 48 | 49 | #include 50 | 51 | // Expands to the qualifier of x, 52 | // where x is either a keyword qualifier or a keyword. 53 | // 54 | // k => forward_reference 55 | // in(k) => in_reference 56 | // out(k) => out_reference 57 | // in_out(k) => in_out_reference 58 | // forward(k) => forward_reference 59 | // consume(k) => consume_reference 60 | // move_from(k) => move_from_reference 61 | #define BOOST_PARAMETER_GET_QUALIFIER(x) \ 62 | BOOST_PP_IIF( \ 63 | BOOST_PARAMETER_IS_QUALIFIER(x) \ 64 | , BOOST_PARAMETER_GET_QUALIFIER_GET(x) \ 65 | , forward_reference \ 66 | ) 67 | /**/ 68 | 69 | // Expands to the unqualified version of x, 70 | // where x is either a keyword qualifier or a keyword. 71 | // 72 | // k => k 73 | // in(k) => k 74 | // out(k) => k 75 | // in_out(k) => k 76 | // forward(k) => k 77 | // consume(k) => k 78 | // move_from(k) => k 79 | #define BOOST_PARAMETER_UNQUALIFIED(x) \ 80 | BOOST_PP_IIF( \ 81 | BOOST_PARAMETER_IS_QUALIFIER(x) \ 82 | , BOOST_PARAMETER_GET_UNQUALIFIED(x) \ 83 | , x \ 84 | ) 85 | /**/ 86 | 87 | #endif // include guard 88 | 89 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pp_impl/unwrap_predicate.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PP_IMPL_UNWRAP_PREDICATE_HPP 7 | #define BOOST_PARAMETER_AUX_PP_IMPL_UNWRAP_PREDICATE_HPP 8 | 9 | namespace boost { namespace parameter { namespace aux { 10 | 11 | // Given Match, which is "void x" where x is an argument matching 12 | // criterion, extract a corresponding MPL predicate. 13 | template 14 | struct unwrap_predicate; 15 | }}} // namespace boost::parameter::aux 16 | 17 | #include 18 | 19 | namespace boost { namespace parameter { namespace aux { 20 | 21 | // Match anything 22 | template <> 23 | struct unwrap_predicate 24 | { 25 | typedef ::boost::parameter::aux::always_true_predicate type; 26 | }; 27 | }}} // namespace boost::parameter::aux 28 | 29 | #include 30 | 31 | #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) 32 | #include 33 | #endif 34 | 35 | namespace boost { namespace parameter { namespace aux { 36 | 37 | // A matching predicate is explicitly specified. 38 | #if BOOST_WORKAROUND(__SUNPRO_CC, BOOST_TESTED_AT(0x580)) 39 | template 40 | struct unwrap_predicate< ::boost::parameter::aux::voidstar(Predicate)> 41 | { 42 | typedef Predicate type; 43 | }; 44 | #else 45 | template 46 | struct unwrap_predicate 47 | { 48 | typedef Predicate type; 49 | }; 50 | #endif // SunProCC workarounds needed. 51 | }}} // namespace boost::parameter::aux 52 | 53 | #include 54 | #include 55 | 56 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 57 | #include 58 | #else 59 | #include 60 | #include 61 | #endif 62 | 63 | namespace boost { namespace parameter { namespace aux { 64 | 65 | // A type to which the argument is supposed to be convertible is 66 | // specified. 67 | template 68 | struct unwrap_predicate 69 | { 70 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 71 | struct type 72 | { 73 | template 74 | struct apply 75 | : ::boost::mpl::if_< 76 | ::std::is_convertible 77 | , ::boost::mpl::true_ 78 | , ::boost::mpl::false_ 79 | > 80 | { 81 | }; 82 | 83 | template 84 | using fn = ::std::is_convertible; 85 | }; 86 | #else 87 | typedef ::boost::mpl::if_< 88 | ::boost::is_convertible< ::boost::mpl::_,Target> 89 | , ::boost::mpl::true_ 90 | , ::boost::mpl::false_ 91 | > type; 92 | #endif // BOOST_PARAMETER_CAN_USE_MP11 93 | }; 94 | }}} // namespace boost::parameter::aux 95 | 96 | #endif // include guard 97 | 98 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/overloads.hpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | // This file generates overloads in this format: 7 | // 8 | // template 9 | // typename ::boost::mpl::apply_wrap1< 10 | // ::boost::parameter::aux::make_arg_list< 11 | // PS0,A0 12 | // , ::boost::parameter::aux::make_arg_list< 13 | // PS1,A1 14 | // , ::boost::mpl::identity< 15 | // ::boost::parameter::aux::empty_arg_list 16 | // > 17 | // > 18 | // > 19 | // , unnamed_list 20 | // >::type 21 | // operator()(A0 const& a0, A1 const& a1) const 22 | // { 23 | // typedef typename ::boost::mpl::apply_wrap1< 24 | // ::boost::parameter::aux::make_arg_list< 25 | // PS0,A0 26 | // , ::boost::parameter::aux::make_arg_list< 27 | // PS1,A1 28 | // , ::boost::mpl::identity< 29 | // ::boost::parameter::aux::empty_arg_list 30 | // > 31 | // > 32 | // > 33 | // >::type arg_tuple; 34 | // 35 | // return arg_tuple( 36 | // a0 37 | // , a1 38 | // , ::boost::parameter::aux::void_() 39 | // ... 40 | // ); 41 | // } 42 | // 43 | 44 | #if !defined(BOOST_PP_IS_ITERATING) 45 | # error Boost.Parameters - do not include this file! 46 | #endif 47 | 48 | #define N BOOST_PP_ITERATION() 49 | 50 | #define BOOST_PARAMETER_open_list(z, n, text) \ 51 | ::boost::parameter::aux::item< \ 52 | BOOST_PP_CAT(PS, n), BOOST_PP_CAT(A, n) 53 | 54 | #define BOOST_PARAMETER_close_list(z, n, text) > 55 | 56 | #define BOOST_PARAMETER_arg_list(n) \ 57 | ::boost::parameter::aux::make_arg_list< \ 58 | BOOST_PP_ENUM(N, BOOST_PARAMETER_open_list, _) \ 59 | , ::boost::parameter::void_ \ 60 | BOOST_PP_REPEAT(N, BOOST_PARAMETER_close_list, _) \ 61 | , deduced_list \ 62 | , ::boost::parameter::aux::tag_keyword_arg \ 63 | > 64 | 65 | #define BOOST_PARAMETER_arg_pack_init(z, n, limit) \ 66 | BOOST_PP_CAT(a, BOOST_PP_SUB(limit, n)) 67 | 68 | template 69 | typename ::boost::mpl::first< 70 | typename BOOST_PARAMETER_arg_list(N)::type 71 | >::type 72 | operator()(BOOST_PP_ENUM_BINARY_PARAMS(N, A, & a)) const 73 | { 74 | typedef typename BOOST_PARAMETER_arg_list(N)::type result; 75 | typedef typename ::boost::mpl::first::type result_type; 76 | typedef typename ::boost::mpl::second::type error; 77 | error(); 78 | 79 | return result_type( 80 | BOOST_PP_ENUM(N, BOOST_PARAMETER_arg_pack_init, BOOST_PP_DEC(N)) 81 | BOOST_PP_ENUM_TRAILING_PARAMS( 82 | BOOST_PP_SUB(BOOST_PARAMETER_COMPOSE_MAX_ARITY, N) 83 | , ::boost::parameter::aux::void_reference() BOOST_PP_INTERCEPT 84 | ) 85 | ); 86 | } 87 | 88 | #undef BOOST_PARAMETER_arg_list 89 | #undef BOOST_PARAMETER_close_list 90 | #undef BOOST_PARAMETER_open_list 91 | #undef N 92 | 93 | -------------------------------------------------------------------------------- /test/optional_deduced_sfinae.cpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #include 7 | 8 | #if (BOOST_PARAMETER_MAX_ARITY < 2) 9 | #error Define BOOST_PARAMETER_MAX_ARITY as 2 or greater. 10 | #endif 11 | #if !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) && \ 12 | (BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY < 2) 13 | #error Define BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY \ 14 | as 2 or greater. 15 | #endif 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 25 | #include 26 | #include 27 | #else 28 | #include 29 | #include 30 | #include 31 | #endif 32 | 33 | namespace test { 34 | 35 | BOOST_PARAMETER_NAME(x) 36 | 37 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 38 | template 39 | using predicate = std::is_convertible; 40 | 41 | BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag, 42 | (deduced 43 | (optional 44 | (x 45 | , *(boost::mp11::mp_quote) 46 | , static_cast(BOOST_PARAMETER_AUX_PP_NULLPTR) 47 | ) 48 | ) 49 | ) 50 | ) 51 | #else // !defined(BOOST_PARAMETER_CAN_USE_MP11) 52 | struct predicate 53 | { 54 | template 55 | struct apply 56 | : boost::mpl::if_< 57 | boost::is_convertible 58 | , boost::mpl::true_ 59 | , boost::mpl::false_ 60 | > 61 | { 62 | }; 63 | }; 64 | 65 | BOOST_PARAMETER_FUNCTION((int), sfinae, test::tag, 66 | (deduced 67 | (optional 68 | (x 69 | , *(test::predicate) 70 | , static_cast(BOOST_PARAMETER_AUX_PP_NULLPTR) 71 | ) 72 | ) 73 | ) 74 | ) 75 | #endif // BOOST_PARAMETER_CAN_USE_MP11 76 | { 77 | return 1; 78 | } 79 | 80 | template 81 | typename boost::enable_if< 82 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 83 | std::is_same 84 | #else 85 | typename boost::mpl::if_< 86 | boost::is_same 87 | , boost::mpl::true_ 88 | , boost::mpl::false_ 89 | >::type 90 | #endif 91 | , int 92 | >::type 93 | sfinae(A0 const& a0) 94 | { 95 | return 0; 96 | } 97 | } // namespace test 98 | 99 | #include 100 | 101 | int main() 102 | { 103 | BOOST_TEST_EQ(1, test::sfinae()); 104 | BOOST_TEST_EQ(1, test::sfinae("foo")); 105 | BOOST_TEST_EQ(0, test::sfinae(1)); 106 | return boost::report_errors(); 107 | } 108 | 109 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/is_tagged_argument.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin, David Abrahams 2005. 2 | // Copyright Cromwell D. Enage 2017. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_PARAMETER_IS_TAGGED_ARGUMENT_HPP 8 | #define BOOST_PARAMETER_IS_TAGGED_ARGUMENT_HPP 9 | 10 | namespace boost { namespace parameter { namespace aux { 11 | 12 | struct tagged_argument_base 13 | { 14 | }; 15 | }}} // namespace boost::parameter::aux 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) || \ 22 | (0 < BOOST_PARAMETER_EXPONENTIAL_OVERLOAD_THRESHOLD_ARITY) 23 | #include 24 | #include 25 | #include 26 | 27 | namespace boost { namespace parameter { namespace aux { 28 | 29 | // This metafunction identifies tagged_argument specializations 30 | // and their derived classes. 31 | template 32 | struct is_tagged_argument 33 | : ::boost::mpl::if_< 34 | // Cannot use is_convertible<> to check if T is derived from 35 | // tagged_argument_base. -- Cromwell D. Enage 36 | ::boost::is_base_of< 37 | ::boost::parameter::aux::tagged_argument_base 38 | , typename ::boost::remove_const< 39 | typename ::boost::remove_reference::type 40 | >::type 41 | > 42 | , ::boost::mpl::true_ 43 | , ::boost::mpl::false_ 44 | >::type 45 | { 46 | }; 47 | }}} // namespace boost::parameter::aux 48 | 49 | #else // no perfect forwarding support and no exponential overloads 50 | #include 51 | #include 52 | 53 | namespace boost { namespace parameter { namespace aux { 54 | 55 | template 56 | struct is_tagged_argument_aux 57 | : ::boost::is_convertible< 58 | T* 59 | , ::boost::parameter::aux::tagged_argument_base const* 60 | > 61 | { 62 | }; 63 | 64 | // This metafunction identifies tagged_argument specializations 65 | // and their derived classes. 66 | template 67 | struct is_tagged_argument 68 | : ::boost::mpl::if_< 69 | ::boost::is_lvalue_reference 70 | , ::boost::mpl::false_ 71 | , ::boost::parameter::aux::is_tagged_argument_aux 72 | >::type 73 | { 74 | }; 75 | }}} // namespace boost::parameter::aux 76 | 77 | #endif // perfect forwarding support, or exponential overloads 78 | 79 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 80 | #include 81 | 82 | namespace boost { namespace parameter { namespace aux { 83 | 84 | template 85 | using is_tagged_argument_mp11 = ::std::is_base_of< 86 | ::boost::parameter::aux::tagged_argument_base 87 | , typename ::std::remove_const< 88 | typename ::std::remove_reference::type 89 | >::type 90 | >; 91 | }}} // namespace boost::parameter::aux 92 | 93 | #endif // BOOST_PARAMETER_CAN_USE_MP11 94 | #endif // include guard 95 | 96 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/pp_impl/argument_pack.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Copyright Cromwell D. Enage 2017. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_PARAMETER_AUX_PP_IMPL_ARGUMENT_PACK_HPP 8 | #define BOOST_PARAMETER_AUX_PP_IMPL_ARGUMENT_PACK_HPP 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 15 | #include 16 | 17 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 18 | #include 19 | #include 20 | #else 21 | #include 22 | #include 23 | #endif 24 | 25 | namespace boost { namespace parameter { namespace aux { 26 | 27 | template 28 | struct argument_pack 29 | { 30 | typedef typename ::boost::parameter::aux::make_arg_list< 31 | typename ::boost::parameter::aux::make_parameter_spec_items< 32 | typename Parameters::parameter_spec 33 | , Args... 34 | >::type 35 | , typename Parameters::deduced_list 36 | , ::boost::parameter::aux::tag_keyword_arg 37 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 38 | , ::boost::mp11::mp_false 39 | #else 40 | , ::boost::mpl::false_ 41 | #endif 42 | >::type result; 43 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 44 | using type = ::boost::mp11::mp_at_c; 45 | #else 46 | typedef typename ::boost::mpl::first::type type; 47 | #endif 48 | }; 49 | }}} // namespace boost::parameter::aux 50 | 51 | #else // !defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 52 | #include 53 | #include 54 | #include 55 | #include 56 | #include 57 | #include 58 | #include 59 | 60 | namespace boost { namespace parameter { namespace aux { 61 | 62 | template < 63 | typename Parameters 64 | BOOST_PP_ENUM_TRAILING_BINARY_PARAMS( 65 | BOOST_PARAMETER_MAX_ARITY 66 | , typename A 67 | , = ::boost::parameter::void_ BOOST_PP_INTERCEPT 68 | ) 69 | > 70 | struct argument_pack 71 | { 72 | typedef typename ::boost::parameter::aux::make_arg_list< 73 | typename BOOST_PARAMETER_build_arg_list( 74 | BOOST_PARAMETER_MAX_ARITY 75 | , ::boost::parameter::aux::make_items 76 | , typename Parameters::parameter_spec 77 | , A 78 | )::type 79 | , typename Parameters::deduced_list 80 | , ::boost::parameter::aux::tag_keyword_arg 81 | , ::boost::mpl::false_ 82 | >::type result; 83 | typedef typename ::boost::mpl::first::type type; 84 | }; 85 | }}} // namespace boost::parameter::aux 86 | 87 | #include 88 | 89 | #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING 90 | #endif // include guard 91 | 92 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2017 Edward Diener 2 | # Copyright 2017 Cromwell D. Enage 3 | # Copyright 2021-2025 Andrey Semashev 4 | # Distributed under the Boost Software License, Version 1.0. 5 | # (See accompanying file LICENSE_1_0.txt or copy at 6 | # http://boost.org/LICENSE_1_0.txt) 7 | 8 | version: 1.0.{build}-{branch} 9 | 10 | shallow_clone: true 11 | 12 | branches: 13 | only: 14 | - master 15 | - develop 16 | - /feature\/.*/ 17 | 18 | environment: 19 | matrix: 20 | - ARGS: toolset=msvc-14.0 address-model=32,64 cxxstd=14,latest 21 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 22 | - ARGS: toolset=msvc-14.1 address-model=32,64 cxxstd=14,17,latest 23 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 24 | - ARGS: toolset=msvc-14.2 address-model=32,64 cxxstd=14,17,20,latest 25 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 26 | - ARGS: toolset=msvc-14.3 address-model=32,64 cxxstd=14,17,20,latest 27 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022 28 | - ARGS: toolset=clang-win address-model=64 cxxstd=14,17,latest 29 | ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat 30 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 31 | - ARGS: toolset=clang-win address-model=32 cxxstd=14,17,latest 32 | ENV_SCRIPT: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars32.bat 33 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 34 | - ARGS: toolset=gcc address-model=32 cxxstd=11,14,1z 35 | PATH: C:\cygwin\bin;%PATH% 36 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 37 | - ARGS: toolset=gcc address-model=64 cxxstd=11,14,1z 38 | PATH: C:\cygwin64\bin;%PATH% 39 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 40 | - ARGS: toolset=gcc address-model=32 cxxstd=11,14 41 | PATH: C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin;%PATH% 42 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 43 | - ARGS: toolset=gcc address-model=64 cxxstd=11,14,1z 44 | PATH: C:\mingw-w64\x86_64-7.3.0-posix-seh-rt_v5-rev0\mingw64\bin;%PATH% 45 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 46 | - ARGS: toolset=gcc address-model=64 cxxstd=11,14,17,2a 47 | PATH: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64\bin;%PATH% 48 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 49 | - ARGS: toolset=gcc address-model=32 cxxstd=11,14,17,2a 50 | PATH: C:\mingw-w64\i686-8.1.0-posix-dwarf-rt_v6-rev0\mingw32\bin;%PATH% 51 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 52 | 53 | install: 54 | - set GIT_FETCH_JOBS=8 55 | - set BOOST_BRANCH=develop 56 | - if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master 57 | - cd .. 58 | - git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root 59 | - cd boost-root 60 | - git submodule init tools/build 61 | - git submodule init tools/boostdep 62 | - git submodule init tools/boost_install 63 | - git submodule init libs/headers 64 | - git submodule init libs/config 65 | - git submodule update --jobs %GIT_FETCH_JOBS% 66 | - xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\parameter 67 | - python tools/boostdep/depinst/depinst.py --git_args "--jobs %GIT_FETCH_JOBS%" parameter 68 | - cmd /c bootstrap 69 | - b2 -d0 headers 70 | 71 | build: off 72 | 73 | test_script: 74 | - if not "%ENV_SCRIPT%" == "" call "%ENV_SCRIPT%" 75 | - b2 -j %NUMBER_OF_PROCESSORS% libs/parameter/test %ARGS% 76 | -------------------------------------------------------------------------------- /test/timings.txt: -------------------------------------------------------------------------------- 1 | # Copyright David Abrahams 2005. Distributed under the Boost 2 | # Software License, Version 1.0. (See accompanying 3 | # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | 5 | ----------------- Test #1 ---------------- 6 | Testers: 7 | Matthias Troyer, Michael Gauckler, David Abrahams 8 | 9 | Date: 10 | 2005-09-09 11 | 12 | Compiler: 13 | Cygwin g++-4.0.0 14 | 15 | Command lines: 16 | g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops \ 17 | -O3 -finline-functions -Wno-inline -DNDEBUG efficiency.cpp 18 | 19 | g++ -o efficiency.exe efficiency.o -Wl,--strip-all 20 | 21 | efficiency && efficiency && efficiency 22 | 23 | Machine: 24 | Dell Inspiron 9300 25 | Intel(R) Pentium(R) M processor 2.00GHz 26 | Running on 230 volts AC power 27 | 28 | Timings: 29 | Run #1 results discarded per standard practice 30 | 31 | Run #2 32 | plain time: 0.75 33 | named parameter time: 0.734 34 | 35 | Run #3 36 | plain time: 0.781 37 | named parameter time: 0.766 38 | 39 | ----------------- Test #2 ---------------- 40 | 41 | Testers: 42 | Chris Frey 43 | 44 | Date: 45 | 2005-09-17 46 | 47 | Compiler: 48 | Linux kernel 2.4.27 49 | gcc version 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8) 50 | 51 | Command lines: 52 | g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops \ 53 | -O3 -finline-functions -Wno-inline -DNDEBUG efficiency.cpp 54 | 55 | g++ -o efficiency.exe efficiency.o -Wl,--strip-all 56 | 57 | Machine: 58 | IBM Thinkpad 770Z, running on AC power 59 | Intel Pentium II 366Mhz 60 | 61 | Timings: 62 | Run #1 results discarded per standard practice 63 | 64 | Run #2 65 | plain time: 6.42 66 | named parameter time: 7.34 67 | 68 | Run #3 69 | plain time: 6.42 70 | named parameter time: 7.34 71 | 72 | ----------------- Test #2 ---------------- 73 | 74 | Testers: 75 | Stuar Dootson 76 | 77 | Date: 78 | 2005-09-18 79 | 80 | Machine: 81 | Athlon 64 3500+ laptop, running on AC power 82 | Windows XP SP2 83 | 84 | 85 | Compiler: Visual C++ 7.1 86 | 87 | command line: 88 | cl -O2 efficiency.cpp -EHsc -I\lib\boost\include\boost-1_33 89 | 90 | Results: 91 | plain time: 92 | named parameter time: 93 | plain time: 1.453 94 | named parameter time: 1.437 95 | plain time: 1.453 96 | named parameter time: 1.453 97 | 98 | Compiler: Visual C++ 8.0 99 | 100 | command-line: 101 | cl -O2 efficiency.cpp -EHsc -I\lib\boost\include\boost-1_33 102 | 103 | Results: 104 | plain time: 105 | named parameter time: 106 | plain time: 1.438 107 | named parameter time: 1.453 108 | plain time: 1.438 109 | named parameter time: 1.437 110 | 111 | Compiler: Mingw gcc 3.4.2 112 | 113 | command-line: 114 | g++ -c -o efficiency.o -ftemplate-depth-100 -funroll-loops -O3 115 | -finline-functions -Wno-inline -DNDEBUG efficiency.cpp 116 | -I\lib\boost\include\boost-1_33 117 | g++ -o efficiency.exe efficiency.o -Wl,--strip-all 118 | 119 | Results: 120 | plain time: 121 | named parameter time: 122 | plain time: 1.14 123 | named parameter time: 1.422 124 | plain time: 1.125 125 | named parameter time: 1.406 126 | 127 | ----------------------------------------- 128 | 129 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/preprocessor/impl/split_args.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_SPLIT_ARGS_HPP 7 | #define BOOST_PARAMETER_AUX_PREPROCESSOR_IMPL_SPLIT_ARGS_HPP 8 | 9 | #include 10 | 11 | // Accessor macros for the split_args tuple. 12 | #define BOOST_PARAMETER_SPLIT_ARG_REQ_COUNT(x) BOOST_PP_TUPLE_ELEM(4, 0, x) 13 | #define BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(x) BOOST_PP_TUPLE_ELEM(4, 1, x) 14 | #define BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(x) BOOST_PP_TUPLE_ELEM(4, 2, x) 15 | #define BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(x) BOOST_PP_TUPLE_ELEM(4, 3, x) 16 | 17 | #include 18 | #include 19 | 20 | // Helper macros for BOOST_PARAMETER_FUNCTION_SPLIT_ARGS. 21 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(s_a, arg) \ 22 | ( \ 23 | BOOST_PP_INC(BOOST_PARAMETER_SPLIT_ARG_REQ_COUNT(s_a)) \ 24 | , BOOST_PP_SEQ_PUSH_BACK(BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(s_a), arg) \ 25 | , BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(s_a) \ 26 | , BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(s_a) \ 27 | ) 28 | /**/ 29 | 30 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_required(split_args, arg) \ 31 | BOOST_PARAMETER_FUNCTION_SPLIT_ARG_required(split_args, arg) 32 | /**/ 33 | 34 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(s_a, arg) \ 35 | ( \ 36 | BOOST_PARAMETER_SPLIT_ARG_REQ_COUNT(s_a) \ 37 | , BOOST_PARAMETER_SPLIT_ARG_REQ_SEQ(s_a) \ 38 | , BOOST_PP_INC(BOOST_PARAMETER_SPLIT_ARG_OPT_COUNT(s_a)) \ 39 | , BOOST_PP_SEQ_PUSH_BACK(BOOST_PARAMETER_SPLIT_ARG_OPT_SEQ(s_a), arg) \ 40 | ) 41 | /**/ 42 | 43 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG_deduced_optional(split_args, arg) \ 44 | BOOST_PARAMETER_FUNCTION_SPLIT_ARG_optional(split_args, arg) 45 | /**/ 46 | 47 | #include 48 | #include 49 | 50 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARG(s, split_args, arg) \ 51 | BOOST_PP_CAT( \ 52 | BOOST_PARAMETER_FUNCTION_SPLIT_ARG_ \ 53 | , BOOST_PARAMETER_FN_ARG_QUALIFIER(arg) \ 54 | )(split_args, arg) 55 | /**/ 56 | 57 | #include 58 | #include 59 | 60 | // Expands from the flattened BOOST_PARAMETER_FUNCTION et. al. arg sequence to 61 | // the tuple (required_count, required_args, optional_count, optional_args). 62 | #define BOOST_PARAMETER_FUNCTION_SPLIT_ARGS(args) \ 63 | BOOST_PP_SEQ_FOLD_LEFT( \ 64 | BOOST_PARAMETER_FUNCTION_SPLIT_ARG \ 65 | , (0, BOOST_PP_SEQ_NIL, 0, BOOST_PP_SEQ_NIL) \ 66 | , args \ 67 | ) 68 | /**/ 69 | 70 | #endif // include guard 71 | 72 | -------------------------------------------------------------------------------- /include/boost/parameter/template_keyword.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Copyright Cromwell D. Enage 2017. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #ifndef BOOST_PARAMETER_TEMPLATE_KEYWORD_HPP 8 | #define BOOST_PARAMETER_TEMPLATE_KEYWORD_HPP 9 | 10 | #include 11 | #include 12 | 13 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 14 | #include 15 | #include 16 | #include 17 | #else 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #endif 26 | 27 | namespace boost { namespace parameter { 28 | 29 | template 30 | struct template_keyword : ::boost::parameter::aux::template_keyword_base 31 | { 32 | typedef Tag key_type; 33 | typedef T value_type; 34 | 35 | // reference is needed for two reasons: 36 | // 37 | // 1. It is used in the body of arg_list<...> 38 | // 39 | // 2. It is the result of binding<...>, which we mistakenly told 40 | // people to use instead of value_type<...> to access named 41 | // template parameters 42 | // 43 | // It used to be that reference == value_type, but that broke when 44 | // the argument was a function or array type, because various 45 | // arg_list functions return reference. 46 | // 47 | // Simply making reference == value_type& would break all the 48 | // legacy code that uses binding<...> to access named template 49 | // parameters. -- David Abrahams 50 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 51 | using reference = typename ::boost::mp11::mp_eval_if< 52 | ::boost::mp11::mp_if< 53 | ::std::is_function 54 | , ::boost::mp11::mp_true 55 | , ::std::is_array 56 | > 57 | , ::std::add_lvalue_reference 58 | , ::boost::mp11::mp_identity 59 | , value_type 60 | >::type; 61 | #else 62 | typedef typename ::boost::mpl::eval_if< 63 | typename ::boost::mpl::if_< 64 | ::boost::is_function 65 | , ::boost::mpl::true_ 66 | , ::boost::is_array 67 | >::type 68 | , ::boost::add_lvalue_reference 69 | , ::boost::mpl::identity 70 | >::type reference; 71 | #endif // BOOST_PARAMETER_CAN_USE_MP11 72 | }; 73 | }} // namespace boost::parameter 74 | 75 | #define BOOST_PARAMETER_TEMPLATE_KEYWORD(name) \ 76 | namespace tag \ 77 | { \ 78 | struct name; \ 79 | } \ 80 | template \ 81 | struct name : ::boost::parameter::template_keyword \ 82 | { \ 83 | }; 84 | /**/ 85 | 86 | #endif // include guard 87 | 88 | -------------------------------------------------------------------------------- /test/basics.cpp: -------------------------------------------------------------------------------- 1 | // Copyright David Abrahams, Daniel Wallin 2003. 2 | // Copyright Cromwell D. Enage 2017. 3 | // Distributed under the Boost Software License, Version 1.0. 4 | // (See accompanying file LICENSE_1_0.txt or copy at 5 | // http://www.boost.org/LICENSE_1_0.txt) 6 | 7 | #include 8 | #include 9 | #include "basics.hpp" 10 | 11 | namespace test { 12 | 13 | // A separate function for getting the "value" key, so we can deduce F 14 | // and use lazy_binding on it. 15 | template 16 | typename boost::parameter::lazy_binding::type 17 | extract_value(Params const& p, F const& f) 18 | { 19 | typename boost::parameter::lazy_binding< 20 | Params,test::tag::value,F 21 | >::type v = p[test::_value || f]; 22 | return v; 23 | } 24 | 25 | template 26 | int f_impl(Params const& p) 27 | { 28 | typename boost::parameter::binding::type 29 | n = p[test::_name]; 30 | 31 | typename boost::parameter::binding< 32 | Params,test::tag::value,double 33 | >::type v = test::extract_value(p, boost::bind(&test::value_default)); 34 | 35 | typename boost::parameter::binding::type 36 | i = p[test::_index | 999]; 37 | 38 | p[test::_tester](n, v, i); 39 | 40 | return 1; 41 | } 42 | 43 | #if defined(BOOST_PARAMETER_HAS_PERFECT_FORWARDING) 44 | template 45 | int f(Args const&... args) 46 | { 47 | return test::f_impl(test::f_parameters()(args...)); 48 | } 49 | #else 50 | template 51 | int f(A0 const& a0, A1 const& a1, A2 const& a2, A3 const& a3) 52 | { 53 | return test::f_impl(test::f_parameters()(a0, a1, a2, a3)); 54 | } 55 | 56 | template 57 | int f(A0 const& a0, A1 const& a1, A2 const& a2) 58 | { 59 | return test::f_impl(test::f_parameters()(a0, a1, a2)); 60 | } 61 | 62 | template 63 | int f(A0 const& a0, A1 const& a1) 64 | { 65 | return test::f_impl(test::f_parameters()(a0, a1)); 66 | } 67 | #endif // BOOST_PARAMETER_HAS_PERFECT_FORWARDING 68 | 69 | template 70 | int f_list(Params const& params) 71 | { 72 | return test::f_impl(params); 73 | } 74 | } 75 | 76 | #include 77 | #include 78 | #include 79 | 80 | int main() 81 | { 82 | test::f( 83 | test::values( 84 | std::string("foo") 85 | , std::string("bar") 86 | , std::string("baz") 87 | ) 88 | , std::string("foo") 89 | , std::string("bar") 90 | , std::string("baz") 91 | ); 92 | 93 | int x = 56; 94 | test::f( 95 | test::values(std::string("foo"), 666.222, 56) 96 | , test::_index = boost::ref(x) 97 | , test::_name = std::string("foo") 98 | ); 99 | 100 | #if !BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) 101 | x = 56; 102 | test::f_list(( 103 | test::_tester = test::values(std::string("foo"), 666.222, 56) 104 | , test::_index = boost::ref(x) 105 | , test::_name = std::string("foo") 106 | )); 107 | #endif // No comma operator available on Borland. 108 | 109 | #if defined(LIBS_PARAMETER_TEST_COMPILE_FAILURE) 110 | test::f(test::_index = 56, test::_name = 55); // won't compile 111 | #endif 112 | 113 | return boost::report_errors(); 114 | } 115 | 116 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/set.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Daniel Wallin 2006. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_SET_060912_HPP 7 | #define BOOST_PARAMETER_SET_060912_HPP 8 | 9 | #include 10 | 11 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 12 | #include 13 | 14 | namespace boost { namespace parameter { namespace aux { 15 | 16 | typedef ::boost::mp11::mp_list<> set0; 17 | }}} // namespace boost::parameter::aux 18 | 19 | #include 20 | 21 | namespace boost { namespace parameter { namespace aux { 22 | 23 | template 24 | struct insert_ 25 | { 26 | using type = ::boost::mp11::mp_insert_c; 27 | }; 28 | }}} // namespace boost::parameter::aux 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace boost { namespace parameter { namespace aux { 35 | 36 | template 37 | struct has_key_ 38 | { 39 | using type = ::boost::mp11::mp_if< 40 | ::boost::mp11::mp_empty 41 | , ::boost::mp11::mp_false 42 | , ::std::is_same< 43 | ::boost::mp11::mp_find 44 | , ::boost::mp11::mp_size 45 | > 46 | >; 47 | }; 48 | }}} // namespace boost::parameter::aux 49 | 50 | #elif BOOST_WORKAROUND(BOOST_BORLANDC, BOOST_TESTED_AT(0x564)) 51 | #include 52 | 53 | namespace boost { namespace parameter { namespace aux { 54 | 55 | typedef ::boost::mpl::list0<> set0; 56 | }}} // namespace boost::parameter::aux 57 | 58 | #include 59 | 60 | namespace boost { namespace parameter { namespace aux { 61 | 62 | template 63 | struct insert_ : ::boost::mpl::push_front 64 | { 65 | }; 66 | }}} // namespace boost::parameter::aux 67 | 68 | #include 69 | #include 70 | #include 71 | #include 72 | #include 73 | 74 | namespace boost { namespace parameter { namespace aux { 75 | 76 | template 77 | struct has_key_ 78 | { 79 | typedef typename ::boost::mpl::find::type iter; 80 | typedef typename ::boost::mpl::if_< 81 | ::boost::is_same::type> 82 | , ::boost::mpl::false_ 83 | , ::boost::mpl::true_ 84 | >::type type; 85 | }; 86 | }}} // namespace boost::parameter::aux 87 | 88 | #else // !BOOST_PARAMETER_CAN_USE_MP11 && Borland workarounds not needed 89 | #include 90 | 91 | namespace boost { namespace parameter { namespace aux { 92 | 93 | typedef ::boost::mpl::set0<> set0; 94 | }}} // namespace boost::parameter::aux 95 | 96 | #include 97 | 98 | namespace boost { namespace parameter { namespace aux { 99 | 100 | template 101 | struct insert_ : ::boost::mpl::insert 102 | { 103 | }; 104 | }}} // namespace boost::parameter::aux 105 | 106 | #include 107 | 108 | namespace boost { namespace parameter { namespace aux { 109 | 110 | template 111 | struct has_key_ : ::boost::mpl::has_key 112 | { 113 | }; 114 | }}} // namespace boost::parameter::aux 115 | 116 | #endif // BOOST_PARAMETER_CAN_USE_MP11 || Borland workarounds needed 117 | #endif // include guard 118 | 119 | -------------------------------------------------------------------------------- /include/boost/parameter/aux_/has_nested_template_fn.hpp: -------------------------------------------------------------------------------- 1 | // Copyright Cromwell D. Enage 2019. 2 | // Distributed under the Boost Software License, Version 1.0. 3 | // (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | 6 | #ifndef BOOST_PARAMETER_AUX_HAS_NESTED_TEMPLATE_FN_HPP 7 | #define BOOST_PARAMETER_AUX_HAS_NESTED_TEMPLATE_FN_HPP 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 14 | #include 15 | #include 16 | #else 17 | #include 18 | #include 19 | #endif 20 | 21 | namespace boost { namespace parameter { namespace aux { 22 | 23 | #if defined(BOOST_PARAMETER_CAN_USE_MP11) 24 | template