// Copyright Daniel Wallin, David Abrahams 2005. 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) #ifndef BOOST_PARAMETER_TAGGED_ARGUMENT_050328_HPP # define BOOST_PARAMETER_TAGGED_ARGUMENT_050328_HPP # include # include # include # include # include # include # include # include # include # include namespace boost { namespace parameter { namespace aux { struct empty_arg_list; struct arg_list_tag; struct tagged_argument_base {}; // Holds a reference to an argument of type Arg associated with // keyword Keyword template struct tagged_argument : tagged_argument_base { typedef Keyword key_type; typedef Arg value_type; typedef Arg& reference; tagged_argument(reference x) : value(x) {} // A metafunction class that, given a keyword and a default // type, returns the appropriate result type for a keyword // lookup given that default struct binding { template struct apply { typedef typename mpl::eval_if< boost::is_same , mpl::if_ , mpl::identity >::type type; }; }; // Comma operator to compose argument list without using parameters<>. // Useful for argument lists with undetermined length. template arg_list< tagged_argument , arg_list > > operator,(tagged_argument x) const { return arg_list< tagged_argument , arg_list > >( *this , arg_list >(x, empty_arg_list()) ); } reference operator[](keyword const&) const { return value; } # if defined(BOOST_NO_FUNCTION_TEMPLATE_ORDERING) || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) template Default& get_with_default(default_ const& x, int) const { return x.value; } template reference get_with_default(default_ const&, long) const { return value; } template typename mpl::apply_wrap3::type operator[](default_ const& x) const { return get_with_default(x, 0L); } template typename result_of0::type get_with_lazy_default(lazy_default const& x, int) const { return x.compute_default(); } template reference get_with_lazy_default(lazy_default const&, long) const { return value; } template typename mpl::apply_wrap3< binding,KW , typename result_of0::type , mpl::true_ >::type operator[](lazy_default const& x) const { return get_with_lazy_default(x, 0L); } # else template reference operator[](default_ const& x) const { return value; } template reference operator[](lazy_default const& x) const { return value; } template Default& operator[](default_ const& x) const { return x.value; } template typename result_of0::type operator[](lazy_default const& x) const { return x.compute_default(); } template static typename ParameterRequirements::has_default satisfies(ParameterRequirements*); template static typename mpl::apply1::type satisfies( parameter_requirements* ); # endif reference value; # if BOOST_WORKAROUND(BOOST_MSVC, BOOST_TESTED_AT(1310)) // warning suppression private: void operator=(tagged_argument const&); public: # endif // MPL sequence support typedef tagged_argument type; // Convenience for users typedef empty_arg_list tail_type; // For the benefit of iterators typedef arg_list_tag tag; // For dispatching to sequence intrinsics }; // Defines a metafunction, is_tagged_argument, that identifies // tagged_argument specializations and their derived classes. template struct is_tagged_argument_aux : is_convertible {}; template struct is_tagged_argument : mpl::and_< mpl::not_ > , is_tagged_argument_aux > {}; }}} // namespace boost::parameter::aux #endif // BOOST_PARAMETER_TAGGED_ARGUMENT_050328_HPP