mirror of
https://github.com/boostorg/utility.git
synced 2025-08-02 14:24:30 +02:00
cleanup
[SVN r1890]
This commit is contained in:
@@ -4,31 +4,19 @@
|
|||||||
// http://www.boost.org/LICENSE_1_0.txt)
|
// http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
#include <boost/named_params.hpp>
|
#include <boost/named_params.hpp>
|
||||||
#include <boost/type_traits/is_convertible.hpp>
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
//#include <iostream>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/ref.hpp>
|
#include <boost/ref.hpp>
|
||||||
/*
|
|
||||||
BOOST_NAMED_PARAMS_FUN(int, f, 0, 3, f_keywords)
|
|
||||||
{
|
|
||||||
return p[index];
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace test
|
namespace test
|
||||||
{
|
{
|
||||||
|
|
||||||
using boost::keyword;
|
using boost::keyword;
|
||||||
using boost::keywords;
|
using boost::keywords;
|
||||||
using boost::arg;
|
using boost::named_param;
|
||||||
|
|
||||||
struct name_t
|
|
||||||
{
|
|
||||||
// At some point maybe we should use has_xxx to allow this
|
|
||||||
typedef boost::is_convertible<boost::mpl::_1, const char*> predicate;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
struct name_t;
|
||||||
keyword<name_t> name;
|
keyword<name_t> name;
|
||||||
|
|
||||||
struct value_t;
|
struct value_t;
|
||||||
@@ -40,68 +28,48 @@ namespace test
|
|||||||
struct tester_t;
|
struct tester_t;
|
||||||
keyword<tester_t> tester;
|
keyword<tester_t> tester;
|
||||||
|
|
||||||
struct X
|
|
||||||
{
|
|
||||||
X(const char*) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
struct convertible_from
|
|
||||||
{
|
|
||||||
template<class U>
|
|
||||||
struct apply : boost::is_convertible<U, T>
|
|
||||||
{};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct f_keywords // vc6 is happier with inheritance than with a typedef
|
struct f_keywords // vc6 is happier with inheritance than with a typedef
|
||||||
: keywords<
|
: keywords<
|
||||||
tester_t
|
tester_t
|
||||||
, arg<name_t, boost::mpl::false_, convertible_from<const char*> >
|
, name_t
|
||||||
, value_t
|
, value_t
|
||||||
, index_t
|
, index_t
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
|
||||||
struct value_default
|
double value_default()
|
||||||
{
|
{
|
||||||
typedef double result_type;
|
return 666.222;
|
||||||
|
}
|
||||||
double operator()() const
|
|
||||||
{
|
|
||||||
return 666.222;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template<class Params>
|
template<class Params>
|
||||||
int f_impl(const Params& p)
|
int f_impl(const Params& p)
|
||||||
{
|
{
|
||||||
p[tester](
|
p[tester](
|
||||||
p[name]
|
p[name]
|
||||||
, p[value || value_default() ]
|
, p[value || boost::bind(&value_default) ]
|
||||||
, p[index | 999]
|
, p[index | 999]
|
||||||
);
|
);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class Tester, class Name, class Value, class Index>
|
template<class Tester, class Name, class Value, class Index>
|
||||||
int f(Tester const& t, const Name& name_, const Value& value_, const Index& index_,
|
int f(Tester const& t, const Name& name_,
|
||||||
typename f_keywords::restrict<Tester, Name, Value, Index>::type x = f_keywords())
|
const Value& value_, const Index& index_)
|
||||||
{
|
{
|
||||||
return f_impl(x(t, name_, value_, index_));
|
return f_impl(f_keywords()(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_)
|
||||||
typename f_keywords::restrict<Tester, Name, Value>::type x = f_keywords())
|
|
||||||
{
|
{
|
||||||
return f_impl(x(t, name_, value_));
|
return f_impl(f_keywords()(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_)
|
||||||
typename f_keywords::restrict<Tester, Name>::type x = f_keywords())
|
|
||||||
{
|
{
|
||||||
return f_impl(x(t, name_));
|
return f_impl(f_keywords()(t, name_));
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
|
Reference in New Issue
Block a user