[Fusion] BOOST_FUSION_ADAPT_STRUCT with templated member
The following piece of code:
#include
2012/9/14 Nevin Liber:
The following piece of code:
#include
template
struct AB {}; BOOST_FUSION_ADAPT_STRUCT( , Silly, (AB<2,3>, ab))
fails with:
main.cpp:8:15: error: macro "BOOST_FUSION_ADAPT_STRUCT" passed 3 arguments, but takes just 2 main.cpp:6:1: error: 'BOOST_FUSION_ADAPT_STRUCT' does not name a type
I am assuming this is because the preprocessor splits line 8 into 'AB<2', '3>', 'ab'.
How do I work around this?
Hi, Use BOOST_FUSION_ADAPT_TPL_STRUCT: http://www.boost.org/doc/libs/1_51_0/libs/fusion/doc/html/fusion/adapted/ada... -- Regards, niXman ___________________________________________________ Dual-target(32 & 64 bit) MinGW compilers for 32 and 64 bit Windows: http://sourceforge.net/projects/mingwbuilds/
On 14 September 2012 11:29, niXman
Use BOOST_FUSION_ADAPT_TPL_STRUCT:
http://www.boost.org/doc/libs/1_51_0/libs/fusion/doc/html/fusion/adapted/ada...
That looks to be for adapting a templated struct. I'm just looking to instantiate a templated type in my non-templated struct. (Note: I had actually meant BOOST_FUSION_DEFINE_STRUCT, but it suffers from the same problem.)
--
Nevin ":-)" Liber mailto:nevin@eviloverlord.com (847) 691-1404
AMDG On 09/14/2012 09:25 AM, Nevin Liber wrote:
The following piece of code:
#include
template
struct AB {}; BOOST_FUSION_ADAPT_STRUCT( , Silly, (AB<2,3>, ab))
fails with:
main.cpp:8:15: error: macro "BOOST_FUSION_ADAPT_STRUCT" passed 3 arguments, but takes just 2 main.cpp:6:1: error: 'BOOST_FUSION_ADAPT_STRUCT' does not name a type
I am assuming this is because the preprocessor splits line 8 into 'AB<2', '3>', 'ab'.
How do I work around this?
typedef? In Christ, Steven Watanabe
On 14 September 2012 12:43, Steven Watanabe
#include
template
struct AB {}; BOOST_FUSION_ADAPT_STRUCT( , Silly, (AB<2,3>, ab))
fails
How do I work around this?
typedef?
I was hoping for something more scalable. Amongst other things, the real code has a number of boost::array of varying types of sizes, so it is either a lot of typedefs or a lot of wrapper classes to get the number of template arguments down to one. -- Nevin ":-)" Liber mailto:nevin@eviloverlord.com (847) 691-1404
AMDG On 09/14/2012 11:24 AM, Nevin Liber wrote:
On 14 September 2012 12:43, Steven Watanabe
wrote: #include
template
struct AB {}; BOOST_FUSION_ADAPT_STRUCT( , Silly, (AB<2,3>, ab))
fails
<snip>
I was hoping for something more scalable. Amongst other things, the real code has a number of boost::array of varying types of sizes, so it is either a lot of typedefs or a lot of wrapper classes to get the number of template arguments down to one.
There's this trick:
function_traits
Hi.
I think it can be solved by using the BOOST_IDENTITY_TYPE.
#include
maybe another solution is #define AB<2,3> MYABTYPE BOOST_FUSION_ADAPT_STRUCT( , Silly, (MYABTYPE, ab)) #undef MYABTYPE 2 lines more, but sometimes it makes the code a bit more readable. On 2012-09-15 01:43, osyo manga wrote:
Hi.
I think it can be solved by using the BOOST_IDENTITY_TYPE.
#include
#include template
struct AB {}; struct Silly{ AB<2,3> ab; };
BOOST_FUSION_ADAPT_STRUCT( Silly, (BOOST_IDENTITY_TYPE((AB<2,3>)), ab))
::Silly s;
BOOST_IDENTITY_TYPE can be used from Boost 1.50.0.
http://www.boost.org/doc/libs/release/libs/utility/identity_type/doc/html/in...
Thanks. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
On 14 September 2012 14:35, Steven Watanabe
There's this trick: function_traits
)>::arg1_type. Unfortunately, this loses CV qualifiers.
That works (and BOOST_IDENTITY_TYPE is just a wrapper around that trick). I'm not worried about the CV qualifiers, as using them on member variables is rare in our code base. Thanks, -- Nevin ":-)" Liber mailto:nevin@eviloverlord.com (847) 691-1404
On 9/15/12 12:25 AM, Nevin Liber wrote:
The following piece of code:
#include
template
struct AB {}; BOOST_FUSION_ADAPT_STRUCT( , Silly, (AB<2,3>, ab))
fails with:
main.cpp:8:15: error: macro "BOOST_FUSION_ADAPT_STRUCT" passed 3 arguments, but takes just 2 main.cpp:6:1: error: 'BOOST_FUSION_ADAPT_STRUCT' does not name a type
I am assuming this is because the preprocessor splits line 8 into 'AB<2', '3>', 'ab'.
How do I work around this?
Will: http://tinyurl.com/96j45k6 help you? Regards, -- Joel de Guzman http://www.boostpro.com http://boost-spirit.com
On 9/19/12 11:49 PM, Joel de Guzman wrote:
On 9/15/12 12:25 AM, Nevin Liber wrote:
The following piece of code:
#include
template
struct AB {}; BOOST_FUSION_ADAPT_STRUCT( , Silly, (AB<2,3>, ab))
fails with:
main.cpp:8:15: error: macro "BOOST_FUSION_ADAPT_STRUCT" passed 3 arguments, but takes just 2 main.cpp:6:1: error: 'BOOST_FUSION_ADAPT_STRUCT' does not name a type
I am assuming this is because the preprocessor splits line 8 into 'AB<2', '3>', 'ab'.
How do I work around this?
Will:
help you?
Ah hit send before I could understand more. Please disregard. Regards, -- Joel de Guzman http://www.boostpro.com http://boost-spirit.com
participants (6)
-
Joel de Guzman
-
Nevin Liber
-
niXman
-
Oswin Krause
-
osyo manga
-
Steven Watanabe