Boost.Fusion macro expansion

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Boost.Fusion macro expansion

Boost - Users mailing list
Hi Peeps

Can anyone tell me what's wrong with this? I think macro expansion is going awry, but I'm not sure why. Do I really have to typedef the map<...> type to keep Fusion happy?

Thx.

#include<string>
#include<map>

#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <boost/fusion/include/define_struct.hpp>

BOOST_FUSION_DEFINE_STRUCT(
  (demo), curves,
  ((std::map<std::string, std::string>), futures)
  ((std::map<std::string, std::string>), credit_curves)
  )

int main( )
{
  return 0;
}

> make
fusion.cpp|9 col 39| error: invalid declarator before ‘)’ token                                              
||    ((std::map<std::string, std::string>), futures) 


Kind Regards

Rob.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Boost.Fusion macro expansion

Boost - Users mailing list
From looking at the docs, is it because you're wrapping the member type in parens?

BOOST_FUSION_DEFINE_STRUCT(
    (namespace0)(namespace1)...,
    struct_name,
    (member_type0, member_name0)
    (member_type1, member_name1)
    ...
    )

that is, have you tried:

BOOST_FUSION_DEFINE_STRUCT(
  (demo), curves,
  (std::map<std::string, std::string>, futures)
  (std::map<std::string, std::string>, credit_curves)
  )

On 30 July 2017 at 17:25, Robert Jones via Boost-users <[hidden email]> wrote:
Hi Peeps

Can anyone tell me what's wrong with this? I think macro expansion is going awry, but I'm not sure why. Do I really have to typedef the map<...> type to keep Fusion happy?

Thx.

#include<string>
#include<map>

#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <boost/fusion/include/define_struct.hpp>

BOOST_FUSION_DEFINE_STRUCT(
  (demo), curves,
  ((std::map<std::string, std::string>), futures)
  ((std::map<std::string, std::string>), credit_curves)
  )

int main( )
{
  return 0;
}

> make
fusion.cpp|9 col 39| error: invalid declarator before ‘)’ token                                              
||    ((std::map<std::string, std::string>), futures) 


Kind Regards

Rob.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Boost.Fusion macro expansion

Boost - Users mailing list
Yeah, that was my first version, which failed, and I figured the problem was the commas in the maps, which
would be interpreted as argument separators by the macro processor. As far as I'm aware the usual solution
is to parenthesise the comma containing arguments, but in this case that seems to blow up inside Fuion.


On 31 July 2017 at 00:56, Steve Lorimer via Boost-users <[hidden email]> wrote:
From looking at the docs, is it because you're wrapping the member type in parens?

BOOST_FUSION_DEFINE_STRUCT(
    (namespace0)(namespace1)...,
    struct_name,
    (member_type0, member_name0)
    (member_type1, member_name1)
    ...
    )

that is, have you tried:

BOOST_FUSION_DEFINE_STRUCT(
  (demo), curves,
  (std::map<std::string, std::string>, futures)
  (std::map<std::string, std::string>, credit_curves)
  )

On 30 July 2017 at 17:25, Robert Jones via Boost-users <[hidden email]> wrote:
Hi Peeps

Can anyone tell me what's wrong with this? I think macro expansion is going awry, but I'm not sure why. Do I really have to typedef the map<...> type to keep Fusion happy?

Thx.

#include<string>
#include<map>

#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <boost/fusion/include/define_struct.hpp>

BOOST_FUSION_DEFINE_STRUCT(
  (demo), curves,
  ((std::map<std::string, std::string>), futures)
  ((std::map<std::string, std::string>), credit_curves)
  )

int main( )
{
  return 0;
}

> make
fusion.cpp|9 col 39| error: invalid declarator before ‘)’ token                                              
||    ((std::map<std::string, std::string>), futures) 


Kind Regards

Rob.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Boost.Fusion macro expansion

Boost - Users mailing list

In such cases you just typedef those comma-containing types and pass the typedef names to macros.

HTH,
Gevorg


On Tue, 1 Aug 2017, 01:31 Robert Jones via Boost-users, <[hidden email]> wrote:
Yeah, that was my first version, which failed, and I figured the problem was the commas in the maps, which
would be interpreted as argument separators by the macro processor. As far as I'm aware the usual solution
is to parenthesise the comma containing arguments, but in this case that seems to blow up inside Fuion.



On 31 July 2017 at 00:56, Steve Lorimer via Boost-users <[hidden email]> wrote:
From looking at the docs, is it because you're wrapping the member type in parens?

BOOST_FUSION_DEFINE_STRUCT(
    (namespace0)(namespace1)...,
    struct_name,
    (member_type0, member_name0)
    (member_type1, member_name1)
    ...
    )

that is, have you tried:

BOOST_FUSION_DEFINE_STRUCT(
  (demo), curves,
  (std::map<std::string, std::string>, futures)
  (std::map<std::string, std::string>, credit_curves)
  )

On 30 July 2017 at 17:25, Robert Jones via Boost-users <[hidden email]> wrote:
Hi Peeps

Can anyone tell me what's wrong with this? I think macro expansion is going awry, but I'm not sure why. Do I really have to typedef the map<...> type to keep Fusion happy?

Thx.

#include<string>
#include<map>

#include <boost/fusion/adapted/struct/define_struct.hpp>
#include <boost/fusion/include/define_struct.hpp>

BOOST_FUSION_DEFINE_STRUCT(
  (demo), curves,
  ((std::map<std::string, std::string>), futures)
  ((std::map<std::string, std::string>), credit_curves)
  )

int main( )
{
  return 0;
}

> make
fusion.cpp|9 col 39| error: invalid declarator before ‘)’ token                                              
||    ((std::map<std::string, std::string>), futures) 


Kind Regards

Rob.


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Loading...