mirror of
https://github.com/boostorg/utility.git
synced 2025-08-02 14:24:30 +02:00
more tests
[SVN r1891]
This commit is contained in:
@@ -10,6 +10,7 @@ import testing ;
|
||||
: [ run lexicographic_test.cpp ]
|
||||
[ run lex_performance_test.cpp ]
|
||||
[ run named_params_test.cpp ]
|
||||
[ run named_params_sfinae.cpp ]
|
||||
[ run enable_if_constructors.cpp ]
|
||||
[ run enable_if_member_templates.cpp ]
|
||||
[ run enable_if_dummy_arg_disambiguation.cpp ]
|
||||
|
56
test/named_params_sfinae.cpp
Executable file
56
test/named_params_sfinae.cpp
Executable file
@@ -0,0 +1,56 @@
|
||||
// Copyright David Abrahams, Daniel Wallin 2003. Use, modification and
|
||||
// distribution is subject to the Boost Software License, Version 1.0.
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/named_params.hpp>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
namespace test
|
||||
{
|
||||
using boost::keyword;
|
||||
using boost::keywords;
|
||||
using boost::named_param;
|
||||
|
||||
struct name_t; keyword<name_t> name;
|
||||
struct value_t; keyword<value_t> value;
|
||||
|
||||
struct f_keywords
|
||||
: keywords<
|
||||
named_param<
|
||||
name_t
|
||||
, boost::mpl::true_
|
||||
, boost::is_convertible<boost::mpl::_, std::string>
|
||||
>
|
||||
, named_param<
|
||||
value_t
|
||||
, boost::mpl::true_
|
||||
, boost::is_convertible<boost::mpl::_, float>
|
||||
>
|
||||
>
|
||||
{};
|
||||
|
||||
BOOST_NAMED_PARAMS_FUN(void, f, 0, 2, f_keywords)
|
||||
{
|
||||
std::string s = p[name | "bar"];
|
||||
float v = p[value | 3.f];
|
||||
|
||||
assert(s == "foo");
|
||||
assert(v == 3.f);
|
||||
}
|
||||
|
||||
} // namespace test
|
||||
|
||||
int main()
|
||||
{
|
||||
using test::name;
|
||||
using test::value;
|
||||
using test::f;
|
||||
|
||||
f("foo");
|
||||
f("foo", 3.f);
|
||||
f(value = 3.f, name = "foo");
|
||||
}
|
||||
|
Reference in New Issue
Block a user