Separate predicate from keywords, much commenting, make vc6 happy with

operator= for keywords


[SVN r1704]
This commit is contained in:
Dave Abrahams
2003-10-24 17:11:03 +00:00
parent 9e8c9b92cb
commit cce938a525

View File

@@ -6,40 +6,36 @@
#include <boost/named_params.hpp> #include <boost/named_params.hpp>
#include <boost/type_traits/is_convertible.hpp> #include <boost/type_traits/is_convertible.hpp>
#include <cassert> #include <cassert>
#include <cstring> #include <string.h>
namespace test namespace test
{ {
using boost::keyword; using boost::keyword;
using boost::keywords; using boost::keywords;
using boost::arg;
struct name_t : keyword<name_t>
struct name_t
{ {
// this should go in a wrapper type, like arg<keyword, predicate> // At some point maybe we should use has_xxx to allow this
typedef boost::is_convertible<boost::mpl::_1, const char*> predicate; typedef boost::is_convertible<boost::mpl::_1, const char*> predicate;
using keyword<name_t>::operator=; };
} name;
struct value_t : keyword<value_t> keyword<name_t> name;
{
using keyword<value_t>::operator=;
} value;
struct index_t : keyword<index_t> struct value_t;
{ keyword <value_t> value;
using keyword<index_t>::operator=;
} index;
struct tester_t : keyword<tester_t> struct index_t;
{ keyword<index_t> index;
using keyword<tester_t>::operator=;
} tester; struct tester_t;
keyword<tester_t> tester;
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
, name_t , arg<name_t, boost::mpl::false_, boost::is_convertible<boost::mpl::_1, const char*> >
, value_t , value_t
, index_t , index_t
> >
@@ -85,7 +81,7 @@ namespace test
bool equal(char const* s1, char const* s2) bool equal(char const* s1, char const* s2)
{ {
return !std::strcmp(s1,s2); return !strcmp(s1,s2);
} }
template <class Name, class Value, class Index> template <class Name, class Value, class Index>
@@ -132,14 +128,10 @@ int main()
test::values("foo", "bar", "baz") test::values("foo", "bar", "baz")
, "foo", "bar", "baz" , "foo", "bar", "baz"
); );
f( f(
test::values("foo", 666.222, 56) test::values("foo", 666.222, 56)
#if BOOST_MSVC == 1200 // sadly templated operator= just doesn't work.
, index(56), name("foo")
#else
, index = 56, name = "foo" , index = 56, name = "foo"
#endif
); );
//f(index = 56, name = 55); // won't compile //f(index = 56, name = 55); // won't compile