mirror of
https://github.com/boostorg/utility.git
synced 2025-08-03 14:54:31 +02:00
Cleanups and clarification
[SVN r2555]
This commit is contained in:
@@ -16,8 +16,8 @@ namespace test
|
|||||||
keyword<struct name_> name;
|
keyword<struct name_> name;
|
||||||
keyword<struct value_> value;
|
keyword<struct value_> value;
|
||||||
|
|
||||||
struct f_keywords
|
struct f_parameters
|
||||||
: keywords<
|
: parameters<
|
||||||
optional<
|
optional<
|
||||||
name_
|
name_
|
||||||
, boost::is_convertible<boost::mpl::_, std::string>
|
, boost::is_convertible<boost::mpl::_, std::string>
|
||||||
@@ -29,33 +29,36 @@ namespace test
|
|||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
|
template <class T> struct not_implemented;
|
||||||
|
|
||||||
template<class P>
|
template<class P>
|
||||||
void f_impl(P const& p)
|
void f_impl(P const& p)
|
||||||
{
|
{
|
||||||
std::string s = p[name | "bar"];
|
std::string s = p[name | "bar"];
|
||||||
float v = p[value | 3.f];
|
float v = p[value | 3.f];
|
||||||
|
|
||||||
|
std::cout << "s is " << s << std::endl;
|
||||||
assert(s == "foo");
|
assert(s == "foo");
|
||||||
assert(v == 3.f);
|
assert(v == 3.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void f()
|
void f(...)
|
||||||
{
|
{
|
||||||
f_impl(f_keywords()());
|
f_impl(f_parameters()());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class A0>
|
template<class A0>
|
||||||
void f(A0 const& a0
|
void f(A0 const& a0
|
||||||
, typename f_keywords::restrict<A0>::type = f_keywords())
|
, typename f_parameters::restrict<A0>::type = f_parameters())
|
||||||
{
|
{
|
||||||
f_impl(f_keywords()(a0));
|
f_impl(f_parameters()(a0));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class A0, class A1>
|
template<class A0, class A1>
|
||||||
void f(A0 const& a0, A1 const& a1
|
void f(A0 const& a0, A1 const& a1
|
||||||
, typename f_keywords::restrict<A0, A1>::type = f_keywords())
|
, typename f_parameters::restrict<A0, A1>::type = f_parameters())
|
||||||
{
|
{
|
||||||
f_impl(f_keywords()(a0, a1));
|
f_impl(f_parameters()(a0, a1));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace test
|
} // namespace test
|
||||||
|
@@ -19,8 +19,8 @@ namespace test
|
|||||||
keyword<struct index_> index;
|
keyword<struct index_> index;
|
||||||
keyword<struct tester_> tester;
|
keyword<struct tester_> tester;
|
||||||
|
|
||||||
struct f_keywords // vc6 is happier with inheritance than with a typedef
|
struct f_parameters // vc6 is happier with inheritance than with a typedef
|
||||||
: keywords<
|
: parameters<
|
||||||
tester_
|
tester_
|
||||||
, name_
|
, name_
|
||||||
, value_
|
, value_
|
||||||
@@ -49,19 +49,19 @@ namespace test
|
|||||||
int f(Tester const& t, const Name& name_,
|
int f(Tester const& t, const Name& name_,
|
||||||
const Value& value_, const Index& index_)
|
const Value& value_, const Index& index_)
|
||||||
{
|
{
|
||||||
return f_impl(f_keywords()(t, name_, value_, index_));
|
return f_impl(f_parameters()(t, name_, value_, index_));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Tester, class Name, class Value>
|
template<class Tester, class Name, class Value>
|
||||||
int f(Tester const& t, const Name& name_, const Value& value_)
|
int f(Tester const& t, const Name& name_, const Value& value_)
|
||||||
{
|
{
|
||||||
return f_impl(f_keywords()(t, name_, value_));
|
return f_impl(f_parameters()(t, name_, value_));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Tester, class Name>
|
template<class Tester, class Name>
|
||||||
int f(Tester const& t, const Name& name_)
|
int f(Tester const& t, const Name& name_)
|
||||||
{
|
{
|
||||||
return f_impl(f_keywords()(t, name_));
|
return f_impl(f_parameters()(t, name_));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Params>
|
template<class Params>
|
||||||
@@ -120,7 +120,7 @@ namespace test
|
|||||||
return values_t<Name,Value,Index>(n,v,i);
|
return values_t<Name,Value,Index>(n,v,i);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef f_keywords g_keywords;
|
typedef f_parameters g_parameters;
|
||||||
|
|
||||||
template<class Args>
|
template<class Args>
|
||||||
int g_impl(Args const& args)
|
int g_impl(Args const& args)
|
||||||
@@ -131,13 +131,13 @@ namespace test
|
|||||||
template<class A0>
|
template<class A0>
|
||||||
int g(A0 const& a0)
|
int g(A0 const& a0)
|
||||||
{
|
{
|
||||||
return g_impl(g_keywords(a0));
|
return g_impl(g_parameters(a0));
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class A0, class A1>
|
template<class A0, class A1>
|
||||||
int g(A0 const& a0, A1 const& a1)
|
int g(A0 const& a0, A1 const& a1)
|
||||||
{
|
{
|
||||||
return g_impl(g_keywords(a0, a1));
|
return g_impl(g_parameters(a0, a1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user