Questions tagged [boost-preprocessor]

Boost.Preprocessor is a library of C++ preprocessor metaprogramming tools including repetition and recursion

Boost.Preprocessor is a library of C++ preprocessor metaprogramming tools including repetition and recursion.

158 questions
144
votes
14 answers

How do I show the value of a #define at compile-time?

I am trying to figure out what version of Boost my code thinks it's using. I want to do something like this: #error BOOST_VERSION but the preprocessor does not expand BOOST_VERSION. I know I could print it out at run-time from the program, and I…
Jim Hunziker
  • 11,545
  • 7
  • 50
  • 57
77
votes
4 answers

Is the C99 preprocessor Turing complete?

After discovering the Boost preprocessor's capabilities I found myself wondering: Is the C99 preprocessor Turing complete? If not, what does it lack to not qualify?
Anycorn
  • 46,748
  • 41
  • 153
  • 250
28
votes
5 answers

D_WIN32_WINNT compiler warning with Boost

Not sure what to make of this error. Added -D_WIN32_WINNT=0x0501 to Visual Studio's "Command Line" options under Project Properties but it says it doesn't recognize it and the warning still appears. I am also not sure how to add the Preprocessor…
bobber205
  • 11,636
  • 25
  • 71
  • 97
13
votes
1 answer

Is Boost using legal C++ preprocessing directive syntax?

My (relatively old) C++ compiler choked on this file in Boost, which starts out as: # /* Copyright (C) 2001 # * Housemarque Oy # * http://www.housemarque.com # * # * Distributed under the Boost Software License, Version 1.0. (See # *…
user541686
  • 189,354
  • 112
  • 476
  • 821
12
votes
4 answers

Construct path for #include directive with macro

I would like to have include file paths dynamically created by a macro for a target-configuration-dependent part of my program. for example, I would like to construct a macro that would be invoked like this: #include TARGET_PATH_OF(header.h) Which…
Richard Hodges
  • 64,204
  • 6
  • 75
  • 124
11
votes
3 answers

Can I append to a preprocessor macro?

Is there any way in standard C—or with GNU extensions—to append stuff to a macro definition? E.g., given a macro defined as #define List foo bar can I append bas so that it List expands as if I’d defined it #define List foo bar bas? I was…
J. C. Salomon
  • 3,693
  • 2
  • 26
  • 36
9
votes
3 answers

Register a C++ class so that later a function can iterate over all registered classes

I am trying to write an application that is loading its extensions dynamically during runtime. I used Boost Preprocessor library to write a preprocessor function that, given a list of names, declares a class for each name (and make all of them…
grisumbras
  • 750
  • 5
  • 10
8
votes
3 answers

Recursive explicit template instantiation to export symbols for a library

In my previous question I asked is recursive explicit template instantiation possible. I saw that it is indeed possible; however, this instantiation turns out to be effective locally only, the symbols of the recursively instantiated template are not…
H. Brandsmeier
  • 917
  • 4
  • 19
8
votes
1 answer

How do I count the number of macro arguments passed to a variadic macro?

I'm already most of the way there: #include #define COUNT(...) BOOST_PP_VARIADIC_SIZE(__VA_ARGS__) COUNT(1,2,3) COUNT(1,2) COUNT(1) COUNT() Running this with -E flag in GCC outputs the following 3 2 1 1 When what I need…
quant
  • 17,534
  • 24
  • 93
  • 186
6
votes
3 answers

Can BOOST_PP_DEFINED be implemented?

Is it possible to write a function-like C preprocessor macro that returns 1 if its argument is defined, and 0 otherwise? Lets call it BOOST_PP_DEFINED by analogy with the other boost preprocessor macros, which we can assume are also in play: #define…
acm
  • 11,033
  • 5
  • 31
  • 60
5
votes
1 answer

How to iterate over two Boost Preprocessor sequences at the same time?

I was wondering if the following can be done via Boost Preprocessor sequences. (Most of the SO questions as well as Boost Preprocessor examples talk about only 1 sequence) #define seq1 (a)(b)(c) #define seq2 (1)(2)(3) // Now iterate over both of…
skgbanga
  • 1,915
  • 1
  • 11
  • 20
5
votes
2 answers

How to use boost::preprocessor to unzip a sequence?

How to use boost::preprocessor to unzip a sequence of pairs? For example, I have a sequence as below (comma between doesn't matter) (int,x)(double,y)(float,z) or (int,x),(double,y),(float,z) or ((int)(x))((double)(y))((float)(z)) and want to…
user1899020
  • 11,941
  • 15
  • 66
  • 130
5
votes
4 answers

Can we implement a max or min macro, which can take variable arguments (more than two parameters )

I want to implement a new max/min macro, which can take more than two parameter, for example: #define max( ... ) ... and then, I can use it like this: max( p0, p1, p2, p3 ) max( 2, 4, 100 ) max( 1,2,3,4,5,6,7 ) -> 7 if this macro can help us to…
Hikari
  • 293
  • 3
  • 14
4
votes
1 answer

How does boost::function support template class with different length template parameters

I want to use boost preprocessor to declare template classes with different template variable length, basically like what boost::function does. #if !BOOST_PP_IS_ITERATING #ifndef D_EXAMPLE_H #define D_EXAMPLE_H #include #include…
Jason
  • 239
  • 1
  • 3
  • 12
4
votes
1 answer

How to separate the result of macro expansion into different arguments?

I'm writing some Boost.Preprocessor metaprogram, and I have the following problem. Consider the following macros (this is a simplification to illustrate the problem): #define ITERATION_IMPL(p1, p2, p3, p4) ((p1),(p2),(p3),(p4)) #define…
Yakov Galka
  • 61,035
  • 13
  • 128
  • 192
1
2 3
10 11