diff --git a/doc/typeof.qbk b/doc/typeof.qbk index 028030a..4b3169f 100644 --- a/doc/typeof.qbk +++ b/doc/typeof.qbk @@ -578,7 +578,7 @@ but removes the top-level qualifiers, `const&` BOOST_TYPEOF_TPL(expr) [variablelist Arguments -[[expr][a valid c++ expression that has a type]] +[[expr][a valid c++ expression that can be converted to const T&]] ] [h4 Remarks] @@ -602,6 +602,48 @@ which takes care of `typename` inside the `typeof` expression. [endsect] +[section:typo TYPEOF_NESTED_TYPEDEF, TYPEOF_NESTED_TYPEDEF_TPL] + +The `TYPEOF_NESTED_TYPEDEF` macro works in much the same way as the 'TYPEOF' macro does, but +workarounds several compiler deficiencies. + +[h4 Usage] + + BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) + BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) + +[variablelist Arguments +[[name][a valid identifier to nest the typeof operation inside] +[expr][a valid c++ expression that can be converted to const T&]] +] + +[h4 Remarks] + +'typeof_nested_typedef' nests the 'typeof' operation inside a struct. By doing this, the 'typeof' operation +can be split into two steps, deconfusing several compilers (notably VC7.1 and VC8.0) on the way. +This also removes the limitation imposed by `BOOST_TYPEOF_LIMIT_SIZE` and allows you to use 'typeof' on much +larger expressions. + +If you want to use `typeof_nested_typedef` in a template-context, use `BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr)`, +which takes care of `typename` inside the `typeof` expression. + +[h4 Sample Code] + + template + struct result_of_conditional + { + BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,true?A():B()); + typedef typename nested::type type; + }; + + template + result_of_conditional::type min(const A& a,const B& b) + { + return a < b ? a : b; + } + +[endsect] + [endsect] [section:other Other considerations and tips] diff --git a/include/boost/typeof/binding_workaround.hpp b/include/boost/typeof/binding_workaround.hpp index 61e04dd..1b5fc1d 100755 --- a/include/boost/typeof/binding_workaround.hpp +++ b/include/boost/typeof/binding_workaround.hpp @@ -17,8 +17,8 @@ can't bind a function pointer to const T& namespace boost { namespace type_of { - template - sizer, T*>::type> encode(T*, + template + sizer::type> encode(T*, typename enable_if::type>::type* = 0); }} diff --git a/include/boost/typeof/msvc/typeof_impl.hpp b/include/boost/typeof/msvc/typeof_impl.hpp index 1dcd9c4..c297e92 100755 --- a/include/boost/typeof/msvc/typeof_impl.hpp +++ b/include/boost/typeof/msvc/typeof_impl.hpp @@ -10,6 +10,7 @@ # include # include +# include namespace boost { @@ -78,8 +79,8 @@ namespace boost //Typeof code # if BOOST_WORKAROUND(BOOST_MSVC,==1300) - template - struct msvc_typeof_base + template + struct msvc_extract_type { template struct id2type_impl; @@ -87,35 +88,36 @@ namespace boost typedef id2type_impl id2type; }; - template - struct msvc_typeof : msvc_typeof_base + template + struct msvc_register_type : msvc_extract_type { template<> - struct id2type_impl + struct id2type_impl //VC7.0 specific bugfeature { typedef T type; }; }; # else - template - struct msvc_typeof_base + template + struct msvc_extract_type { - struct id2type; }; - template - struct msvc_typeof : msvc_typeof_base + template + struct msvc_register_type : msvc_extract_type { - struct msvc_typeof_base::id2type // This uses nice VC6-VC7 bugfeature + typedef msvc_extract_type base_type; + struct base_type::id2type // This uses nice VC6.5 and VC7.1 bugfeature { typedef T type; }; }; # endif + template struct msvc_typeid_wrapper { - typedef typename msvc_typeof_base::id2type id2type; + typedef typename msvc_extract_type >::id2type id2type; typedef typename id2type::type type; }; //Workaround for ETI-bug for VC6 and VC7 @@ -136,7 +138,7 @@ namespace boost //Get the next available compile time constants index BOOST_STATIC_CONSTANT(unsigned,value=BOOST_TYPEOF_INDEX(T)); //Instantiate the template - typedef typename msvc_typeof::id2type type; + typedef typename msvc_register_type >::id2type type; //Set the next compile time constants index BOOST_STATIC_CONSTANT(unsigned,next=value+1); //Increment the compile time constant (only needed when extensions are not active @@ -153,4 +155,22 @@ namespace boost # define BOOST_TYPEOF_TPL(expr) typename BOOST_TYPEOF(expr) +# define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ + struct name {\ + template\ + static boost::type_of::msvc_register_type _typeof_register_function(const T&);\ + BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(_typeof_register_function(expr)));\ + typedef typename boost::type_of::msvc_extract_type::id2type id2type;\ + typedef typename id2type::type type;\ + }; + +# define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ + struct name {\ + template\ + static boost::type_of::msvc_register_type _typeof_register_function(const T&);\ + BOOST_STATIC_CONSTANT(int,_typeof_register_value=sizeof(_typeof_register_function(expr)));\ + typedef boost::type_of::msvc_extract_type::id2type id2type;\ + typedef id2type::type type;\ + }; + #endif//BOOST_TYPEOF_MSVC_TYPEOF_IMPL_HPP_INCLUDED diff --git a/include/boost/typeof/typeof.hpp b/include/boost/typeof/typeof.hpp index 7b8b932..2e38c08 100755 --- a/include/boost/typeof/typeof.hpp +++ b/include/boost/typeof/typeof.hpp @@ -144,6 +144,14 @@ # define BOOST_TYPEOF(expr) BOOST_TYPEOF_KEYWORD(boost::type_of::ensure_obj(expr)) # define BOOST_TYPEOF_TPL BOOST_TYPEOF +# define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ + struct name {\ + typedef BOOST_TYPEOF_TPL(expr) type;\ + }; +# define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ + struct name {\ + typedef BOOST_TYPEOF(expr) type;\ + }; # endif # define BOOST_TYPEOF_REGISTER_TYPE(x) # define BOOST_TYPEOF_REGISTER_TEMPLATE(x, params) diff --git a/include/boost/typeof/typeof_impl.hpp b/include/boost/typeof/typeof_impl.hpp index 873d0ed..bdd3472 100755 --- a/include/boost/typeof/typeof_impl.hpp +++ b/include/boost/typeof/typeof_impl.hpp @@ -16,8 +16,7 @@ #define BOOST_TYPEOF_sizer_item(z, n, _)\ char item ## n[V::item ## n ::value]; -namespace boost { namespace type_of { - +namespace boost { namespace type_of { template struct sizer { @@ -28,8 +27,8 @@ namespace boost { namespace type_of { BOOST_PP_REPEAT(BOOST_TYPEOF_LIMIT_SIZE, BOOST_TYPEOF_sizer_item, ~) }; - template - sizer, T>::type> encode(const T&); + template + sizer::type> encode(const T&); }} #undef BOOST_TYPEOF_sizer_item @@ -44,7 +43,7 @@ namespace boost { namespace type_of { }} #define BOOST_TYPEOF_TYPEITEM(z, n, expr)\ - boost::mpl::size_t + boost::mpl::size_t >(expr).item ## n)> #define BOOST_TYPEOF_ENCODED_VECTOR(Expr) \ BOOST_TYPEOF_VECTOR(BOOST_TYPEOF_LIMIT_SIZE)< \ @@ -56,4 +55,54 @@ namespace boost { namespace type_of { #define BOOST_TYPEOF_TPL typename BOOST_TYPEOF +//offset_vector is used to delay the insertion of data into the vector in order to allow +//encoding to be done in many steps +namespace boost { namespace type_of { + template + struct offset_vector { + }; + + template + struct push_back,T> { + typedef offset_vector type; + }; + + template + struct push_back >,T> { + typedef typename push_back::type type; + }; +}} + +#define BOOST_TYPEOF_NESTED_TYPEITEM(z, n, expr)\ + BOOST_STATIC_CONSTANT(int,BOOST_PP_CAT(value,n) = sizeof(boost::type_of::encode<_typeof_start_vector>(expr).item ## n));\ + typedef boost::mpl::size_t BOOST_PP_CAT(item,n); + +#define BOOST_TYPEOF_NESTED_TYPEDEF_IMPL(expr) \ + template\ + struct _typeof_encode_fraction {\ + BOOST_STATIC_CONSTANT(int,_typeof_encode_offset = (_Typeof_Iteration*BOOST_TYPEOF_LIMIT_SIZE));\ + typedef boost::type_of::offset_vector,boost::mpl::size_t<_typeof_encode_offset> > _typeof_start_vector;\ + BOOST_PP_REPEAT(BOOST_TYPEOF_LIMIT_SIZE,BOOST_TYPEOF_NESTED_TYPEITEM,expr);\ + };\ + template\ + struct _typeof_fraction_iter {\ + BOOST_STATIC_CONSTANT(int,pos=(Pos::value));\ + BOOST_STATIC_CONSTANT(int,iteration=(pos/BOOST_TYPEOF_LIMIT_SIZE));\ + BOOST_STATIC_CONSTANT(int,where=pos%BOOST_TYPEOF_LIMIT_SIZE);\ + typedef typename boost::type_of::v_iter<_typeof_encode_fraction,boost::mpl::int_ >::type type;\ + typedef _typeof_fraction_iter next;\ + }; + +# define BOOST_TYPEOF_NESTED_TYPEDEF_TPL(name,expr) \ + struct name {\ + BOOST_TYPEOF_NESTED_TYPEDEF_IMPL(expr)\ + typedef typename boost::type_of::decode_type<_typeof_fraction_iter > >::type type;\ + }; + +# define BOOST_TYPEOF_NESTED_TYPEDEF(name,expr) \ + struct name {\ + BOOST_TYPEOF_NESTED_TYPEDEF_IMPL(expr)\ + typedef boost::type_of::decode_type<_typeof_fraction_iter > >::type type;\ + }; + #endif//BOOST_TYPEOF_COMPLIANT_TYPEOF_IMPL_HPP_INCLUDED diff --git a/include/boost/typeof/vector.hpp b/include/boost/typeof/vector.hpp index a4a6a2f..a985914 100755 --- a/include/boost/typeof/vector.hpp +++ b/include/boost/typeof/vector.hpp @@ -84,7 +84,7 @@ namespace boost { namespace type_of { - template struct v_iter; // not defined + template struct v_iter; // not defined # define BOOST_PP_LOCAL_MACRO BOOST_TYPEOF_spec_iter # define BOOST_PP_LOCAL_LIMITS \ (BOOST_PP_DEC(BOOST_TYPEOF_PP_START_SIZE), \ @@ -138,7 +138,10 @@ namespace boost { namespace type_of { namespace boost { namespace type_of { - template struct push_back; // not defined + template struct push_back { + typedef V type; + }; //default behaviour is to let push_back ignore T, and return the input vector. + //This is to let BOOST_TYPEOF_NESTED_TYPEDEF work properly with the default vector. # define BOOST_PP_LOCAL_MACRO BOOST_TYPEOF_spec_push_back # define BOOST_PP_LOCAL_LIMITS \ (BOOST_PP_DEC(BOOST_TYPEOF_PP_START_SIZE), \ diff --git a/include/boost/typeof/vector100.hpp b/include/boost/typeof/vector100.hpp index 74a3ef1..7bbbd11 100755 --- a/include/boost/typeof/vector100.hpp +++ b/include/boost/typeof/vector100.hpp @@ -9,7 +9,7 @@ namespace boost { namespace type_of { - template struct v_iter; + template struct v_iter; // not defined template struct v_iter > { typedef typename V::item0 type; typedef v_iter > next; }; template struct v_iter > { typedef typename V::item1 type; typedef v_iter > next; }; template struct v_iter > { typedef typename V::item2 type; typedef v_iter > next; }; @@ -215,7 +215,9 @@ namespace boost { namespace type_of { template< class P0 , class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 , class P16 , class P17 , class P18 , class P19 , class P20 , class P21 , class P22 , class P23 , class P24 , class P25 , class P26 , class P27 , class P28 , class P29 , class P30 , class P31 , class P32 , class P33 , class P34 , class P35 , class P36 , class P37 , class P38 , class P39 , class P40 , class P41 , class P42 , class P43 , class P44 , class P45 , class P46 , class P47 , class P48 , class P49 , class P50 , class P51 , class P52 , class P53 , class P54 , class P55 , class P56 , class P57 , class P58 , class P59 , class P60 , class P61 , class P62 , class P63 , class P64 , class P65 , class P66 , class P67 , class P68 , class P69 , class P70 , class P71 , class P72 , class P73 , class P74 , class P75 , class P76 , class P77 , class P78 , class P79 , class P80 , class P81 , class P82 , class P83 , class P84 , class P85 , class P86 , class P87 , class P88 , class P89 , class P90 , class P91 , class P92 , class P93 , class P94 , class P95 , class P96 , class P97 , class P98 , class P99 > struct vector100 { typedef v_iter > begin; typedef P0 item0; typedef P1 item1; typedef P2 item2; typedef P3 item3; typedef P4 item4; typedef P5 item5; typedef P6 item6; typedef P7 item7; typedef P8 item8; typedef P9 item9; typedef P10 item10; typedef P11 item11; typedef P12 item12; typedef P13 item13; typedef P14 item14; typedef P15 item15; typedef P16 item16; typedef P17 item17; typedef P18 item18; typedef P19 item19; typedef P20 item20; typedef P21 item21; typedef P22 item22; typedef P23 item23; typedef P24 item24; typedef P25 item25; typedef P26 item26; typedef P27 item27; typedef P28 item28; typedef P29 item29; typedef P30 item30; typedef P31 item31; typedef P32 item32; typedef P33 item33; typedef P34 item34; typedef P35 item35; typedef P36 item36; typedef P37 item37; typedef P38 item38; typedef P39 item39; typedef P40 item40; typedef P41 item41; typedef P42 item42; typedef P43 item43; typedef P44 item44; typedef P45 item45; typedef P46 item46; typedef P47 item47; typedef P48 item48; typedef P49 item49; typedef P50 item50; typedef P51 item51; typedef P52 item52; typedef P53 item53; typedef P54 item54; typedef P55 item55; typedef P56 item56; typedef P57 item57; typedef P58 item58; typedef P59 item59; typedef P60 item60; typedef P61 item61; typedef P62 item62; typedef P63 item63; typedef P64 item64; typedef P65 item65; typedef P66 item66; typedef P67 item67; typedef P68 item68; typedef P69 item69; typedef P70 item70; typedef P71 item71; typedef P72 item72; typedef P73 item73; typedef P74 item74; typedef P75 item75; typedef P76 item76; typedef P77 item77; typedef P78 item78; typedef P79 item79; typedef P80 item80; typedef P81 item81; typedef P82 item82; typedef P83 item83; typedef P84 item84; typedef P85 item85; typedef P86 item86; typedef P87 item87; typedef P88 item88; typedef P89 item89; typedef P90 item90; typedef P91 item91; typedef P92 item92; typedef P93 item93; typedef P94 item94; typedef P95 item95; typedef P96 item96; typedef P97 item97; typedef P98 item98; typedef P99 item99; typedef mpl::int_<1> item100; typedef mpl::int_<1> item101; typedef mpl::int_<1> item102; typedef mpl::int_<1> item103; typedef mpl::int_<1> item104; typedef mpl::int_<1> item105; typedef mpl::int_<1> item106; typedef mpl::int_<1> item107; typedef mpl::int_<1> item108; typedef mpl::int_<1> item109; typedef mpl::int_<1> item110; typedef mpl::int_<1> item111; typedef mpl::int_<1> item112; typedef mpl::int_<1> item113; typedef mpl::int_<1> item114; typedef mpl::int_<1> item115; typedef mpl::int_<1> item116; typedef mpl::int_<1> item117; typedef mpl::int_<1> item118; typedef mpl::int_<1> item119; typedef mpl::int_<1> item120; typedef mpl::int_<1> item121; typedef mpl::int_<1> item122; typedef mpl::int_<1> item123; typedef mpl::int_<1> item124; typedef mpl::int_<1> item125; typedef mpl::int_<1> item126; typedef mpl::int_<1> item127; typedef mpl::int_<1> item128; typedef mpl::int_<1> item129; typedef mpl::int_<1> item130; typedef mpl::int_<1> item131; typedef mpl::int_<1> item132; typedef mpl::int_<1> item133; typedef mpl::int_<1> item134; typedef mpl::int_<1> item135; typedef mpl::int_<1> item136; typedef mpl::int_<1> item137; typedef mpl::int_<1> item138; typedef mpl::int_<1> item139; typedef mpl::int_<1> item140; typedef mpl::int_<1> item141; typedef mpl::int_<1> item142; typedef mpl::int_<1> item143; typedef mpl::int_<1> item144; typedef mpl::int_<1> item145; typedef mpl::int_<1> item146; typedef mpl::int_<1> item147; typedef mpl::int_<1> item148; }; }} namespace boost { namespace type_of { - template struct push_back; + template struct push_back { + typedef V type; + }; template< class T> struct push_back, T> { typedef boost::type_of::vector1< T > type; }; template< class P0 , class T> struct push_back, T> { typedef boost::type_of::vector2< P0 , T > type; }; template< class P0 , class P1 , class T> struct push_back, T> { typedef boost::type_of::vector3< P0 , P1 , T > type; }; diff --git a/include/boost/typeof/vector150.hpp b/include/boost/typeof/vector150.hpp index d7fb7f5..81ccad7 100755 --- a/include/boost/typeof/vector150.hpp +++ b/include/boost/typeof/vector150.hpp @@ -9,7 +9,7 @@ namespace boost { namespace type_of { - template struct v_iter; + template struct v_iter; template struct v_iter > { typedef typename V::item0 type; typedef v_iter > next; }; template struct v_iter > { typedef typename V::item1 type; typedef v_iter > next; }; template struct v_iter > { typedef typename V::item2 type; typedef v_iter > next; }; @@ -315,7 +315,9 @@ namespace boost { namespace type_of { template< class P0 , class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 , class P16 , class P17 , class P18 , class P19 , class P20 , class P21 , class P22 , class P23 , class P24 , class P25 , class P26 , class P27 , class P28 , class P29 , class P30 , class P31 , class P32 , class P33 , class P34 , class P35 , class P36 , class P37 , class P38 , class P39 , class P40 , class P41 , class P42 , class P43 , class P44 , class P45 , class P46 , class P47 , class P48 , class P49 , class P50 , class P51 , class P52 , class P53 , class P54 , class P55 , class P56 , class P57 , class P58 , class P59 , class P60 , class P61 , class P62 , class P63 , class P64 , class P65 , class P66 , class P67 , class P68 , class P69 , class P70 , class P71 , class P72 , class P73 , class P74 , class P75 , class P76 , class P77 , class P78 , class P79 , class P80 , class P81 , class P82 , class P83 , class P84 , class P85 , class P86 , class P87 , class P88 , class P89 , class P90 , class P91 , class P92 , class P93 , class P94 , class P95 , class P96 , class P97 , class P98 , class P99 , class P100 , class P101 , class P102 , class P103 , class P104 , class P105 , class P106 , class P107 , class P108 , class P109 , class P110 , class P111 , class P112 , class P113 , class P114 , class P115 , class P116 , class P117 , class P118 , class P119 , class P120 , class P121 , class P122 , class P123 , class P124 , class P125 , class P126 , class P127 , class P128 , class P129 , class P130 , class P131 , class P132 , class P133 , class P134 , class P135 , class P136 , class P137 , class P138 , class P139 , class P140 , class P141 , class P142 , class P143 , class P144 , class P145 , class P146 , class P147 , class P148 , class P149 > struct vector150 { typedef v_iter > begin; typedef P0 item0; typedef P1 item1; typedef P2 item2; typedef P3 item3; typedef P4 item4; typedef P5 item5; typedef P6 item6; typedef P7 item7; typedef P8 item8; typedef P9 item9; typedef P10 item10; typedef P11 item11; typedef P12 item12; typedef P13 item13; typedef P14 item14; typedef P15 item15; typedef P16 item16; typedef P17 item17; typedef P18 item18; typedef P19 item19; typedef P20 item20; typedef P21 item21; typedef P22 item22; typedef P23 item23; typedef P24 item24; typedef P25 item25; typedef P26 item26; typedef P27 item27; typedef P28 item28; typedef P29 item29; typedef P30 item30; typedef P31 item31; typedef P32 item32; typedef P33 item33; typedef P34 item34; typedef P35 item35; typedef P36 item36; typedef P37 item37; typedef P38 item38; typedef P39 item39; typedef P40 item40; typedef P41 item41; typedef P42 item42; typedef P43 item43; typedef P44 item44; typedef P45 item45; typedef P46 item46; typedef P47 item47; typedef P48 item48; typedef P49 item49; typedef P50 item50; typedef P51 item51; typedef P52 item52; typedef P53 item53; typedef P54 item54; typedef P55 item55; typedef P56 item56; typedef P57 item57; typedef P58 item58; typedef P59 item59; typedef P60 item60; typedef P61 item61; typedef P62 item62; typedef P63 item63; typedef P64 item64; typedef P65 item65; typedef P66 item66; typedef P67 item67; typedef P68 item68; typedef P69 item69; typedef P70 item70; typedef P71 item71; typedef P72 item72; typedef P73 item73; typedef P74 item74; typedef P75 item75; typedef P76 item76; typedef P77 item77; typedef P78 item78; typedef P79 item79; typedef P80 item80; typedef P81 item81; typedef P82 item82; typedef P83 item83; typedef P84 item84; typedef P85 item85; typedef P86 item86; typedef P87 item87; typedef P88 item88; typedef P89 item89; typedef P90 item90; typedef P91 item91; typedef P92 item92; typedef P93 item93; typedef P94 item94; typedef P95 item95; typedef P96 item96; typedef P97 item97; typedef P98 item98; typedef P99 item99; typedef P100 item100; typedef P101 item101; typedef P102 item102; typedef P103 item103; typedef P104 item104; typedef P105 item105; typedef P106 item106; typedef P107 item107; typedef P108 item108; typedef P109 item109; typedef P110 item110; typedef P111 item111; typedef P112 item112; typedef P113 item113; typedef P114 item114; typedef P115 item115; typedef P116 item116; typedef P117 item117; typedef P118 item118; typedef P119 item119; typedef P120 item120; typedef P121 item121; typedef P122 item122; typedef P123 item123; typedef P124 item124; typedef P125 item125; typedef P126 item126; typedef P127 item127; typedef P128 item128; typedef P129 item129; typedef P130 item130; typedef P131 item131; typedef P132 item132; typedef P133 item133; typedef P134 item134; typedef P135 item135; typedef P136 item136; typedef P137 item137; typedef P138 item138; typedef P139 item139; typedef P140 item140; typedef P141 item141; typedef P142 item142; typedef P143 item143; typedef P144 item144; typedef P145 item145; typedef P146 item146; typedef P147 item147; typedef P148 item148; typedef P149 item149; typedef mpl::int_<1> item150; typedef mpl::int_<1> item151; typedef mpl::int_<1> item152; typedef mpl::int_<1> item153; typedef mpl::int_<1> item154; typedef mpl::int_<1> item155; typedef mpl::int_<1> item156; typedef mpl::int_<1> item157; typedef mpl::int_<1> item158; typedef mpl::int_<1> item159; typedef mpl::int_<1> item160; typedef mpl::int_<1> item161; typedef mpl::int_<1> item162; typedef mpl::int_<1> item163; typedef mpl::int_<1> item164; typedef mpl::int_<1> item165; typedef mpl::int_<1> item166; typedef mpl::int_<1> item167; typedef mpl::int_<1> item168; typedef mpl::int_<1> item169; typedef mpl::int_<1> item170; typedef mpl::int_<1> item171; typedef mpl::int_<1> item172; typedef mpl::int_<1> item173; typedef mpl::int_<1> item174; typedef mpl::int_<1> item175; typedef mpl::int_<1> item176; typedef mpl::int_<1> item177; typedef mpl::int_<1> item178; typedef mpl::int_<1> item179; typedef mpl::int_<1> item180; typedef mpl::int_<1> item181; typedef mpl::int_<1> item182; typedef mpl::int_<1> item183; typedef mpl::int_<1> item184; typedef mpl::int_<1> item185; typedef mpl::int_<1> item186; typedef mpl::int_<1> item187; typedef mpl::int_<1> item188; typedef mpl::int_<1> item189; typedef mpl::int_<1> item190; typedef mpl::int_<1> item191; typedef mpl::int_<1> item192; typedef mpl::int_<1> item193; typedef mpl::int_<1> item194; typedef mpl::int_<1> item195; typedef mpl::int_<1> item196; typedef mpl::int_<1> item197; typedef mpl::int_<1> item198; }; }} namespace boost { namespace type_of { - template struct push_back; + template struct push_back { + typedef V type; + }; template< class T> struct push_back, T> { typedef boost::type_of::vector1< T > type; }; template< class P0 , class T> struct push_back, T> { typedef boost::type_of::vector2< P0 , T > type; }; template< class P0 , class P1 , class T> struct push_back, T> { typedef boost::type_of::vector3< P0 , P1 , T > type; }; diff --git a/include/boost/typeof/vector200.hpp b/include/boost/typeof/vector200.hpp index 0360008..dfa3a48 100755 --- a/include/boost/typeof/vector200.hpp +++ b/include/boost/typeof/vector200.hpp @@ -9,7 +9,7 @@ namespace boost { namespace type_of { - template struct v_iter; + template struct v_iter; template struct v_iter > { typedef typename V::item0 type; typedef v_iter > next; }; template struct v_iter > { typedef typename V::item1 type; typedef v_iter > next; }; template struct v_iter > { typedef typename V::item2 type; typedef v_iter > next; }; @@ -415,7 +415,9 @@ namespace boost { namespace type_of { template< class P0 , class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 , class P16 , class P17 , class P18 , class P19 , class P20 , class P21 , class P22 , class P23 , class P24 , class P25 , class P26 , class P27 , class P28 , class P29 , class P30 , class P31 , class P32 , class P33 , class P34 , class P35 , class P36 , class P37 , class P38 , class P39 , class P40 , class P41 , class P42 , class P43 , class P44 , class P45 , class P46 , class P47 , class P48 , class P49 , class P50 , class P51 , class P52 , class P53 , class P54 , class P55 , class P56 , class P57 , class P58 , class P59 , class P60 , class P61 , class P62 , class P63 , class P64 , class P65 , class P66 , class P67 , class P68 , class P69 , class P70 , class P71 , class P72 , class P73 , class P74 , class P75 , class P76 , class P77 , class P78 , class P79 , class P80 , class P81 , class P82 , class P83 , class P84 , class P85 , class P86 , class P87 , class P88 , class P89 , class P90 , class P91 , class P92 , class P93 , class P94 , class P95 , class P96 , class P97 , class P98 , class P99 , class P100 , class P101 , class P102 , class P103 , class P104 , class P105 , class P106 , class P107 , class P108 , class P109 , class P110 , class P111 , class P112 , class P113 , class P114 , class P115 , class P116 , class P117 , class P118 , class P119 , class P120 , class P121 , class P122 , class P123 , class P124 , class P125 , class P126 , class P127 , class P128 , class P129 , class P130 , class P131 , class P132 , class P133 , class P134 , class P135 , class P136 , class P137 , class P138 , class P139 , class P140 , class P141 , class P142 , class P143 , class P144 , class P145 , class P146 , class P147 , class P148 , class P149 , class P150 , class P151 , class P152 , class P153 , class P154 , class P155 , class P156 , class P157 , class P158 , class P159 , class P160 , class P161 , class P162 , class P163 , class P164 , class P165 , class P166 , class P167 , class P168 , class P169 , class P170 , class P171 , class P172 , class P173 , class P174 , class P175 , class P176 , class P177 , class P178 , class P179 , class P180 , class P181 , class P182 , class P183 , class P184 , class P185 , class P186 , class P187 , class P188 , class P189 , class P190 , class P191 , class P192 , class P193 , class P194 , class P195 , class P196 , class P197 , class P198 , class P199 > struct vector200 { typedef v_iter > begin; typedef P0 item0; typedef P1 item1; typedef P2 item2; typedef P3 item3; typedef P4 item4; typedef P5 item5; typedef P6 item6; typedef P7 item7; typedef P8 item8; typedef P9 item9; typedef P10 item10; typedef P11 item11; typedef P12 item12; typedef P13 item13; typedef P14 item14; typedef P15 item15; typedef P16 item16; typedef P17 item17; typedef P18 item18; typedef P19 item19; typedef P20 item20; typedef P21 item21; typedef P22 item22; typedef P23 item23; typedef P24 item24; typedef P25 item25; typedef P26 item26; typedef P27 item27; typedef P28 item28; typedef P29 item29; typedef P30 item30; typedef P31 item31; typedef P32 item32; typedef P33 item33; typedef P34 item34; typedef P35 item35; typedef P36 item36; typedef P37 item37; typedef P38 item38; typedef P39 item39; typedef P40 item40; typedef P41 item41; typedef P42 item42; typedef P43 item43; typedef P44 item44; typedef P45 item45; typedef P46 item46; typedef P47 item47; typedef P48 item48; typedef P49 item49; typedef P50 item50; typedef P51 item51; typedef P52 item52; typedef P53 item53; typedef P54 item54; typedef P55 item55; typedef P56 item56; typedef P57 item57; typedef P58 item58; typedef P59 item59; typedef P60 item60; typedef P61 item61; typedef P62 item62; typedef P63 item63; typedef P64 item64; typedef P65 item65; typedef P66 item66; typedef P67 item67; typedef P68 item68; typedef P69 item69; typedef P70 item70; typedef P71 item71; typedef P72 item72; typedef P73 item73; typedef P74 item74; typedef P75 item75; typedef P76 item76; typedef P77 item77; typedef P78 item78; typedef P79 item79; typedef P80 item80; typedef P81 item81; typedef P82 item82; typedef P83 item83; typedef P84 item84; typedef P85 item85; typedef P86 item86; typedef P87 item87; typedef P88 item88; typedef P89 item89; typedef P90 item90; typedef P91 item91; typedef P92 item92; typedef P93 item93; typedef P94 item94; typedef P95 item95; typedef P96 item96; typedef P97 item97; typedef P98 item98; typedef P99 item99; typedef P100 item100; typedef P101 item101; typedef P102 item102; typedef P103 item103; typedef P104 item104; typedef P105 item105; typedef P106 item106; typedef P107 item107; typedef P108 item108; typedef P109 item109; typedef P110 item110; typedef P111 item111; typedef P112 item112; typedef P113 item113; typedef P114 item114; typedef P115 item115; typedef P116 item116; typedef P117 item117; typedef P118 item118; typedef P119 item119; typedef P120 item120; typedef P121 item121; typedef P122 item122; typedef P123 item123; typedef P124 item124; typedef P125 item125; typedef P126 item126; typedef P127 item127; typedef P128 item128; typedef P129 item129; typedef P130 item130; typedef P131 item131; typedef P132 item132; typedef P133 item133; typedef P134 item134; typedef P135 item135; typedef P136 item136; typedef P137 item137; typedef P138 item138; typedef P139 item139; typedef P140 item140; typedef P141 item141; typedef P142 item142; typedef P143 item143; typedef P144 item144; typedef P145 item145; typedef P146 item146; typedef P147 item147; typedef P148 item148; typedef P149 item149; typedef P150 item150; typedef P151 item151; typedef P152 item152; typedef P153 item153; typedef P154 item154; typedef P155 item155; typedef P156 item156; typedef P157 item157; typedef P158 item158; typedef P159 item159; typedef P160 item160; typedef P161 item161; typedef P162 item162; typedef P163 item163; typedef P164 item164; typedef P165 item165; typedef P166 item166; typedef P167 item167; typedef P168 item168; typedef P169 item169; typedef P170 item170; typedef P171 item171; typedef P172 item172; typedef P173 item173; typedef P174 item174; typedef P175 item175; typedef P176 item176; typedef P177 item177; typedef P178 item178; typedef P179 item179; typedef P180 item180; typedef P181 item181; typedef P182 item182; typedef P183 item183; typedef P184 item184; typedef P185 item185; typedef P186 item186; typedef P187 item187; typedef P188 item188; typedef P189 item189; typedef P190 item190; typedef P191 item191; typedef P192 item192; typedef P193 item193; typedef P194 item194; typedef P195 item195; typedef P196 item196; typedef P197 item197; typedef P198 item198; typedef P199 item199; typedef mpl::int_<1> item200; typedef mpl::int_<1> item201; typedef mpl::int_<1> item202; typedef mpl::int_<1> item203; typedef mpl::int_<1> item204; typedef mpl::int_<1> item205; typedef mpl::int_<1> item206; typedef mpl::int_<1> item207; typedef mpl::int_<1> item208; typedef mpl::int_<1> item209; typedef mpl::int_<1> item210; typedef mpl::int_<1> item211; typedef mpl::int_<1> item212; typedef mpl::int_<1> item213; typedef mpl::int_<1> item214; typedef mpl::int_<1> item215; typedef mpl::int_<1> item216; typedef mpl::int_<1> item217; typedef mpl::int_<1> item218; typedef mpl::int_<1> item219; typedef mpl::int_<1> item220; typedef mpl::int_<1> item221; typedef mpl::int_<1> item222; typedef mpl::int_<1> item223; typedef mpl::int_<1> item224; typedef mpl::int_<1> item225; typedef mpl::int_<1> item226; typedef mpl::int_<1> item227; typedef mpl::int_<1> item228; typedef mpl::int_<1> item229; typedef mpl::int_<1> item230; typedef mpl::int_<1> item231; typedef mpl::int_<1> item232; typedef mpl::int_<1> item233; typedef mpl::int_<1> item234; typedef mpl::int_<1> item235; typedef mpl::int_<1> item236; typedef mpl::int_<1> item237; typedef mpl::int_<1> item238; typedef mpl::int_<1> item239; typedef mpl::int_<1> item240; typedef mpl::int_<1> item241; typedef mpl::int_<1> item242; typedef mpl::int_<1> item243; typedef mpl::int_<1> item244; typedef mpl::int_<1> item245; typedef mpl::int_<1> item246; typedef mpl::int_<1> item247; typedef mpl::int_<1> item248; typedef mpl::int_<1> item249; }; }} namespace boost { namespace type_of { - template struct push_back; + template struct push_back { + typedef V type; + }; template< class T> struct push_back, T> { typedef boost::type_of::vector1< T > type; }; template< class P0 , class T> struct push_back, T> { typedef boost::type_of::vector2< P0 , T > type; }; template< class P0 , class P1 , class T> struct push_back, T> { typedef boost::type_of::vector3< P0 , P1 , T > type; }; diff --git a/include/boost/typeof/vector50.hpp b/include/boost/typeof/vector50.hpp index 834840a..3b265d4 100755 --- a/include/boost/typeof/vector50.hpp +++ b/include/boost/typeof/vector50.hpp @@ -9,7 +9,7 @@ namespace boost { namespace type_of { - template struct v_iter; + template struct v_iter; // not defined template struct v_iter > { typedef typename V::item0 type; typedef v_iter > next; }; template struct v_iter > { typedef typename V::item1 type; typedef v_iter > next; }; template struct v_iter > { typedef typename V::item2 type; typedef v_iter > next; }; @@ -115,7 +115,9 @@ namespace boost { namespace type_of { template< class P0 , class P1 , class P2 , class P3 , class P4 , class P5 , class P6 , class P7 , class P8 , class P9 , class P10 , class P11 , class P12 , class P13 , class P14 , class P15 , class P16 , class P17 , class P18 , class P19 , class P20 , class P21 , class P22 , class P23 , class P24 , class P25 , class P26 , class P27 , class P28 , class P29 , class P30 , class P31 , class P32 , class P33 , class P34 , class P35 , class P36 , class P37 , class P38 , class P39 , class P40 , class P41 , class P42 , class P43 , class P44 , class P45 , class P46 , class P47 , class P48 , class P49 > struct vector50 { typedef v_iter > begin; typedef P0 item0; typedef P1 item1; typedef P2 item2; typedef P3 item3; typedef P4 item4; typedef P5 item5; typedef P6 item6; typedef P7 item7; typedef P8 item8; typedef P9 item9; typedef P10 item10; typedef P11 item11; typedef P12 item12; typedef P13 item13; typedef P14 item14; typedef P15 item15; typedef P16 item16; typedef P17 item17; typedef P18 item18; typedef P19 item19; typedef P20 item20; typedef P21 item21; typedef P22 item22; typedef P23 item23; typedef P24 item24; typedef P25 item25; typedef P26 item26; typedef P27 item27; typedef P28 item28; typedef P29 item29; typedef P30 item30; typedef P31 item31; typedef P32 item32; typedef P33 item33; typedef P34 item34; typedef P35 item35; typedef P36 item36; typedef P37 item37; typedef P38 item38; typedef P39 item39; typedef P40 item40; typedef P41 item41; typedef P42 item42; typedef P43 item43; typedef P44 item44; typedef P45 item45; typedef P46 item46; typedef P47 item47; typedef P48 item48; typedef P49 item49; typedef mpl::int_<1> item50; typedef mpl::int_<1> item51; typedef mpl::int_<1> item52; typedef mpl::int_<1> item53; typedef mpl::int_<1> item54; typedef mpl::int_<1> item55; typedef mpl::int_<1> item56; typedef mpl::int_<1> item57; typedef mpl::int_<1> item58; typedef mpl::int_<1> item59; typedef mpl::int_<1> item60; typedef mpl::int_<1> item61; typedef mpl::int_<1> item62; typedef mpl::int_<1> item63; typedef mpl::int_<1> item64; typedef mpl::int_<1> item65; typedef mpl::int_<1> item66; typedef mpl::int_<1> item67; typedef mpl::int_<1> item68; typedef mpl::int_<1> item69; typedef mpl::int_<1> item70; typedef mpl::int_<1> item71; typedef mpl::int_<1> item72; typedef mpl::int_<1> item73; typedef mpl::int_<1> item74; typedef mpl::int_<1> item75; typedef mpl::int_<1> item76; typedef mpl::int_<1> item77; typedef mpl::int_<1> item78; typedef mpl::int_<1> item79; typedef mpl::int_<1> item80; typedef mpl::int_<1> item81; typedef mpl::int_<1> item82; typedef mpl::int_<1> item83; typedef mpl::int_<1> item84; typedef mpl::int_<1> item85; typedef mpl::int_<1> item86; typedef mpl::int_<1> item87; typedef mpl::int_<1> item88; typedef mpl::int_<1> item89; typedef mpl::int_<1> item90; typedef mpl::int_<1> item91; typedef mpl::int_<1> item92; typedef mpl::int_<1> item93; typedef mpl::int_<1> item94; typedef mpl::int_<1> item95; typedef mpl::int_<1> item96; typedef mpl::int_<1> item97; typedef mpl::int_<1> item98; typedef mpl::int_<1> item99; }; }} namespace boost { namespace type_of { - template struct push_back; + template struct push_back { + typedef V type; + }; template< class T> struct push_back, T> { typedef boost::type_of::vector1< T > type; }; template< class P0 , class T> struct push_back, T> { typedef boost::type_of::vector2< P0 , T > type; }; template< class P0 , class P1 , class T> struct push_back, T> { typedef boost::type_of::vector3< P0 , P1 , T > type; }; diff --git a/test/Jamfile b/test/Jamfile index acd2783..f02d93c 100755 --- a/test/Jamfile +++ b/test/Jamfile @@ -73,4 +73,7 @@ test-suite "typeof" [ compile function_ptr_from_tpl.cpp : BOOST_TYPEOF_NATIVE special-requirements : function_ptr_from_tpl_native ] [ compile function_ptr_from_tpl.cpp : BOOST_TYPEOF_COMPLIANT special-requirements : function_ptr_from_tpl_emulation ] + + [ compile nested_typedef.cpp : BOOST_TYPEOF_NATIVE special-requirements : nested_typedef_native ] + [ compile nested_typedef.cpp : BOOST_TYPEOF_COMPLIANT special-requirements : nested_typedef_emulation ] ; diff --git a/test/nested_typedef.cpp b/test/nested_typedef.cpp new file mode 100644 index 0000000..dc9f370 --- /dev/null +++ b/test/nested_typedef.cpp @@ -0,0 +1,34 @@ + +#include +#include +#include +#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP() + + +void do_int(int) {} + +struct { + template + T operator[](const T&) {} +} int_p; + + +template struct wrap +{ + BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,int_p[& do_int]); + typedef typename nested::type type; +}; + +BOOST_TYPEOF_REGISTER_TEMPLATE(wrap,1) + +template struct parser +{ + struct __rule { + static T & a_placeholder; + BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested,int_p[a_placeholder]); + typedef typename nested::type type; + }; +}; + +BOOST_STATIC_ASSERT((boost::is_same::type,void(*)(int)>::value)); +BOOST_STATIC_ASSERT((boost::is_same >::__rule::type,wrap >::value));