[fusion] Use of FUSION_MAX_VECTOR_SIZE in headers
Hi all,
I'm trying to use fusion vectors with more than 10 elements, but I'm
running into some trouble.
I'm using fusion as an implementation detail of some header-based
tools, which get included (often indirectly) by some translation
units. The tools require large fusion vectors, but I don't want
client code (i.e. the .cpp files) to have to care about this. I was
under the impression that I could just add:
#define FUSION_MAX_VECTOR_SIZE 20
#include
On Tue, Feb 9, 2010 at 3:49 PM, Gabriel Redner
Hi all,
I'm trying to use fusion vectors with more than 10 elements, but I'm running into some trouble.
I'm using fusion as an implementation detail of some header-based tools, which get included (often indirectly) by some translation units. The tools require large fusion vectors, but I don't want client code (i.e. the .cpp files) to have to care about this. I was under the impression that I could just add:
#define FUSION_MAX_VECTOR_SIZE 20 #include
in my tool's header file, and be off to the races. It seems that this works only if no other fusion header has been included previously in the same translation unit:
#include
... #define FUSION_MAX_VECTOR_SIZE 20 #include ... // Error - too many template arguments! boost::fusion::make_vector(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15); I really don't want to have to track down every translation unit which is (usually indirectly) including my tool's header. I am under the impression that boost::function is fine with client code redefining its limit macro and re-including its header, but perhaps fusion does not have the same feature?
I also realize that for vector itself I can just include vectorN.hpp and use vectorN<...>, but if I want to use the generation functions (make_vector, vector_tie) it seems I'm stuck. Is there a workaround, or just something obvious that I'm doing wrong?
make_vector/etc.. just use vector directly internally, you can do the same in their place with the vectorN functions.
On 2/10/2010 11:24 AM, Gabriel Redner wrote:
Yes, I realize that. It still strikes me as a bug.
Call it a bug if you will, but there's no way around it AFAIK. FUSION_MAX_VECTOR_SIZE must be defined before any other fusion include. Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon
On Wed, Feb 10, 2010 at 12:12 AM, Joel de Guzman
On 2/10/2010 11:24 AM, Gabriel Redner wrote:
Yes, I realize that. It still strikes me as a bug.
Call it a bug if you will, but there's no way around it AFAIK. FUSION_MAX_VECTOR_SIZE must be defined before any other fusion include.
Yep, it is a limitation of the current version of C++. When C++1x compilers are common that can be fixed, but not until then.
participants (3)
-
Gabriel Redner
-
Joel de Guzman
-
OvermindDL1