variant<> number of template arguments

Hello,
I have a use of the visitor pattern (this was an answer provided to me on
c++-moderated) as shown below.
Question1: is the maximum number of variant<> arguments extendable?
Question2: Below, some of the variants I have are full template specs.
Is there a way to write the variant<> typedef with templates instead and
have
the operator() of the static visitor a template member.
Rds,
---------------
#include <iostream>
#include

AMDG Hicham Mouline wrote:
Question1: is the maximum number of variant<> arguments extendable?
The easiest way is to use make_variant_over which takes an MPL sequence.
Question2: Below, some of the variants I have are full template specs.
Is there a way to write the variant<> typedef with templates instead and have
the operator() of the static visitor a template member.
I'm not sure what you want. If the members of the variant have a common interface, (For example if they all have a nested integer constant called value) Then you can make the static visitor operator() a template and use this common interface. In Christ, Steven Watanabe

Thank you,
Trying to define the variant, I have:
typedef boost::mpl::vector<> variant_template_arguments;
typedef boost::mpl::vector
Question1: is the maximum number of variant<> arguments extendable?
The easiest way is to use make_variant_over which takes an MPL sequence.
Question2: Below, some of the variants I have are full template specs.
Is there a way to write the variant<> typedef with templates instead and have
the operator() of the static visitor a template member.
I'm not sure what you want. If the members of the variant have a common interface, (For example if they all have a nested integer constant called value) Then you can make the static visitor operator() a template and use this common interface. In Christ, Steven Watanabe

After some research, I found this post: http://lists.boost.org/boost-users/2007/05/27648.php that provides a 2-sequence cartesian product metafunction that I will try to use to have the product of the 3 sequences I have. Rds, -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: 29 May 2008 23:53 To: boost-users@lists.boost.org Subject: Re: [Boost-users] variant<> number of template arguments AMDG Hicham Mouline wrote:
Question1: is the maximum number of variant<> arguments extendable?
The easiest way is to use make_variant_over which takes an MPL sequence.
Question2: Below, some of the variants I have are full template specs.
Is there a way to write the variant<> typedef with templates instead and have
the operator() of the static visitor a template member.
I'm not sure what you want. If the members of the variant have a common interface, (For example if they all have a nested integer constant called value) Then you can make the static visitor operator() a template and use this common interface. In Christ, Steven Watanabe

AMDG
Hicham Mouline wrote:
Question1: is the maximum number of variant<> arguments extendable?
The easiest way is to use make_variant_over which takes an MPL sequence.
It seems make_variant_over is also limited by BOOST_VARIANT_LIMIT_TYPES.
This macro is 20 on 2 platforms (linux-i386-gcc-4.1.2-boost-1.34.1 and
win-i386-vs2005- boost-1.35.0)
on both platforms,
#include <iostream>
#include

AMDG Hicham Mouline wrote:
It seems make_variant_over is also limited by BOOST_VARIANT_LIMIT_TYPES. This macro is 20 on 2 platforms (linux-i386-gcc-4.1.2-boost-1.34.1 and win-i386-vs2005- boost-1.35.0)
<snip>
If I add type19, making the mpc vector have 21 types, compilation fails...
The limit of variant and the limit of mpl::vector happen to be the same.
For more types, try using the numbered form of mpl vector which can
handle up to 50 arguments.
#include

This works thank you very much steven,
I am now trying to implement the cartesian product of 3 sequences
based on the earlier post:
template<typename T> struct pair_with : mpl::pair
{}; Rds, -----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Steven Watanabe Sent: 31 May 2008 20:51 To: boost-users@lists.boost.org Subject: Re: [Boost-users] variant<> number of template arguments AMDG Hicham Mouline wrote:
It seems make_variant_over is also limited by BOOST_VARIANT_LIMIT_TYPES. This macro is 20 on 2 platforms (linux-i386-gcc-4.1.2-boost-1.34.1 and win-i386-vs2005- boost-1.35.0)
<snip>
If I add type19, making the mpc vector have 21 types, compilation fails...
The limit of variant and the limit of mpl::vector happen to be the same.
For more types, try using the numbered form of mpl vector which can
handle up to 50 arguments.
#include

Hello,
1) I now managed to produce the cartesian product of 3 mpl
sequences applying my custom metafunction to the resulting triplets,
however it takes like 40seconds to compile. I doubt this is the optimal
way to write the cartesian product metafunction. (code compiles as-is,
below)
2) By the way, cartesian product hasn't been deemed generic enough to be
included
in the MPL?
3) what would be the equivalent of mpl::pair for 3 or more? boost::tuple or
boost::variant?
Your help is very appreciated, thank you,
#include <iostream>
#include
{};
template
{};
template
It seems make_variant_over is also limited by BOOST_VARIANT_LIMIT_TYPES. This macro is 20 on 2 platforms (linux-i386-gcc-4.1.2-boost-1.34.1 and win-i386-vs2005- boost-1.35.0)
<snip>
If I add type19, making the mpc vector have 21 types, compilation fails...
The limit of variant and the limit of mpl::vector happen to be the same.
For more types, try using the numbered form of mpl vector which can
handle up to 50 arguments.
#include
participants (2)
-
Hicham Mouline
-
Steven Watanabe