x
Yes
No
Do you want to visit DriveHQ English website?
Inicio
Características
Precios
Prueba gratuita
Software cliente
Acerca de nosotros
Servidor de archivos
|
Solución de copias de seguridad
|
Servidor FTP
|
Servidor de correo electrónico
|
Alojamiento web
|
Software cliente
Servidor de archivos
Solución de copia de seguridad
Servidor FTP
Servidor de correo electrónico
Alojamiento web
Software cliente
arg_list.hpp - Hosted on DriveHQ Cloud IT Platform
Arriba
Subir
Descargar
Compartir
Publicar
Nueva carpeta
Nuevo archivo
Copiar
Cortar
Eliminar
Pegar
Clasificación
Actualizar
Ruta de la carpeta: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\parameter\aux_\arg_list.hpp
Girar
Efecto
Propiedad
Historial
// 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 ARG_LIST_050329_HPP #define ARG_LIST_050329_HPP #include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
namespace boost { namespace parameter { // Forward declaration for aux::arg_list, below. template
struct keyword; namespace aux { // Tag type passed to MPL lambda. struct lambda_tag; // // Structures used to build the tuple of actual arguments. The // tuple is a nested cons-style list of arg_list specializations // terminated by an empty_arg_list. // // Each specialization of arg_list is derived from its successor in // the list type. This feature is used along with using // declarations to build member function overload sets that can // match against keywords. // // MPL sequence support struct arg_list_tag; // Terminates arg_list<> and represents an empty list. Since this // is just the terminating case you might want to look at arg_list // first, to get a feel for what's really happening here. struct empty_arg_list { empty_arg_list() {} // Constructor taking BOOST_PARAMETER_MAX_ARITY empty_arg_list // arguments; this makes initialization empty_arg_list( BOOST_PP_ENUM_PARAMS( BOOST_PARAMETER_MAX_ARITY, void_ BOOST_PP_INTERCEPT )) {} // 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 Default type; }; }; #if !BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // Terminator for has_key, indicating that the keyword is unique template
static no_tag has_key(KW*); #endif #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \ || (BOOST_WORKAROUND(__GNUC__, < 3)) \ || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // The overload set technique doesn't work with these older // compilers, so they need some explicit handholding. // A metafunction class that, given a keyword, returns the type // of the base sublist whose get() function can produce the // value for that key struct key_owner { template
struct apply { typedef empty_arg_list type; }; }; template
T& get(default_
x) const { return x.value; } template
typename result_of0
::type get(lazy_default
x) const { return x.compute_default(); } #endif // If this function is called, it means there is no argument // in the list that matches the supplied keyword. Just return // the default value. template
Default& operator[](default_
x) const { return x.value; } // If this function is called, it means there is no argument // in the list that matches the supplied keyword. Just evaluate // and return the default value. template
typename result_of0
::type operator[]( BOOST_PARAMETER_lazy_default_fallback
x) const { return x.compute_default(); } // No argument corresponding to ParameterRequirements::key_type // was found if we match this overload, so unless that parameter // has a default, we indicate that the actual arguments don't // match the function's requirements. template
static typename ParameterRequirements::has_default satisfies(ParameterRequirements*, ArgPack*); // MPL sequence support typedef empty_arg_list type; // convenience typedef arg_list_tag tag; // For dispatching to sequence intrinsics }; #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) template
no_tag operator*(empty_arg_list, KW*); #endif // Forward declaration for arg_list::operator, template
struct tagged_argument; template
struct is_maybe : is_base_and_derived
{}; template
struct get_reference { typedef typename T::reference type; }; // A tuple of tagged arguments, terminated with empty_arg_list. // Every TaggedArg is an instance of tagged_argument<>. template
struct arg_list : Next { typedef arg_list
self; typedef typename TaggedArg::key_type key_type; typedef typename is_maybe
::type holds_maybe; typedef typename mpl::eval_if< holds_maybe , get_reference
, get_reference
>::type reference; typedef typename mpl::if_< holds_maybe , reference , typename TaggedArg::value_type >::type value_type; TaggedArg arg; // Stores the argument // Store the arguments in successive nodes of this list template< // class A0, class A1, ... BOOST_PP_ENUM_PARAMS(BOOST_PARAMETER_MAX_ARITY, class A) > arg_list( // A0& a0, A1& a1, ... BOOST_PP_ENUM_BINARY_PARAMS(BOOST_PARAMETER_MAX_ARITY, A, & a) ) : Next( // a1, a2, ... BOOST_PP_ENUM_SHIFTED_PARAMS(BOOST_PARAMETER_MAX_ARITY, a) , void_reference() ) , arg(a0) {} // Create a new list by prepending arg to a copy of tail. Used // when incrementally building this structure with the comma // operator. arg_list(TaggedArg arg, Next const& tail) : Next(tail) , arg(arg) {} // 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::apply_wrap3
>::type type; }; }; #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && !BOOST_WORKAROUND(__GNUC__, == 2) # if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) friend yes_tag operator*(arg_list, key_type*); # define BOOST_PARAMETER_CALL_HAS_KEY(next, key) (*(next*)0 * (key*)0) # else // Overload for key_type, so the assert below will fire if the // same keyword is used again static yes_tag has_key(key_type*); using Next::has_key; # define BOOST_PARAMETER_CALL_HAS_KEY(next, key) next::has_key((key*)0) # endif BOOST_MPL_ASSERT_MSG( sizeof(BOOST_PARAMETER_CALL_HAS_KEY(Next,key_type)) == sizeof(no_tag) , duplicate_keyword, (key_type) ); # undef BOOST_PARAMETER_CALL_HAS_KEY #endif // // Begin implementation of indexing operators for looking up // specific arguments by name // // Helpers that handle the case when TaggedArg is // empty
. template
reference get_default(D const&, mpl::false_) const { return arg.value; } template
reference get_default(D const& d, mpl::true_) const { return arg.value ? arg.value.get() : arg.value.construct(d.value); } #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) \ || BOOST_WORKAROUND(__GNUC__, < 3) \ || BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) // These older compilers don't support the overload set creation // idiom well, so we need to do all the return type calculation // for the compiler and dispatch through an outer function template // A metafunction class that, given a keyword, returns the base // sublist whose get() function can produce the value for that // key. struct key_owner { template
struct apply { typedef typename mpl::eval_if< boost::is_same
, mpl::identity
> , mpl::apply_wrap1
>::type type; }; }; // Outer indexing operators that dispatch to the right node's // get() function. template
typename mpl::apply_wrap3
::type operator[](keyword
const& x) const { typename mpl::apply_wrap1
::type const& sublist = *this; return sublist.get(x); } template
typename mpl::apply_wrap3
::type operator[](default_
x) const { typename mpl::apply_wrap1
::type const& sublist = *this; return sublist.get(x); } template
typename mpl::apply_wrap3< binding,KW , typename result_of0
::type , mpl::true_ >::type operator[](lazy_default
x) const { typename mpl::apply_wrap1
::type const& sublist = *this; return sublist.get(x); } // These just return the stored value; when empty_arg_list is // reached, indicating no matching argument was passed, the // default is returned, or if no default_ or lazy_default was // passed, compilation fails. reference get(keyword
const&) const { BOOST_MPL_ASSERT_NOT((holds_maybe)); return arg.value; } template
reference get(default_
const& d) const { return get_default(d, holds_maybe()); } template
reference get(lazy_default
) const { return arg.value; } #else reference operator[](keyword
const&) const { BOOST_MPL_ASSERT_NOT((holds_maybe)); return arg.value; } template
reference operator[](default_
const& d) const { return get_default(d, holds_maybe()); } template
reference operator[](lazy_default
) const { return arg.value; } // Builds an overload set including operator[]s defined in base // classes. using Next::operator[]; // // End of indexing support // // // For parameter_requirements matching this node's key_type, // return a bool constant wrapper indicating whether the // requirements are satisfied by TaggedArg. Used only for // compile-time computation and never really called, so a // declaration is enough. // template
static typename mpl::apply_wrap2< typename mpl::lambda
::type , value_type, ArgPack >::type satisfies( parameter_requirements
* , ArgPack* ); // Builds an overload set including satisfies functions defined // in base classes. using Next::satisfies; #endif // Comma operator to compose argument list without using parameters<>. // Useful for argument lists with undetermined length. template
arg_list
, self> operator,(tagged_argument
x) const { return arg_list
, self>(x, *this); } // MPL sequence support typedef self type; // Convenience for users typedef Next tail_type; // For the benefit of iterators typedef arg_list_tag tag; // For dispatching to sequence intrinsics }; #if BOOST_WORKAROUND(BOOST_MSVC, <= 1300) // ETI workaround template <> struct arg_list
{}; #endif // MPL sequence support template
struct arg_list_iterator { typedef mpl::forward_iterator_tag category; // The incremented iterator typedef arg_list_iterator
next; // dereferencing yields the key type typedef typename ArgumentPack::key_type type; }; template <> struct arg_list_iterator
{}; }} // namespace parameter::aux // MPL sequence support namespace mpl { template <> struct begin_impl
{ template
struct apply { typedef parameter::aux::arg_list_iterator
type; }; }; template <> struct end_impl
{ template
struct apply { typedef parameter::aux::arg_list_iterator
type; }; }; } } // namespace boost #endif // ARG_LIST_050329_HPP
arg_list.hpp
Dirección de la página
Dirección del archivo
Anterior 1/15
Siguiente
Descargar
( 13 KB )
Comments
Total ratings:
0
Average rating:
No clasificado
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.