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
4
votes
2 answers

Avoid expansion of macros while using boost preprocessor sequences

I'm trying to get the OS and compiler name as a string in C++. Although there are many questions about this I did not find a definitive answer. So I tried to use Boost.Predef 1.55 which defines macros of the type BOOST_OS_ and…
Flamefire
  • 3,954
  • 2
  • 22
  • 50
4
votes
3 answers

macro which defines new macros with an added prefix

We have a profiling framework which can be enabled and disabled at compile time. All the various calls to the framework are done through macros, eg: PROFILE_START(msg) PROFILE_END(msg) The macros then resolve to the actual profiler call when…
Steve Lorimer
  • 22,912
  • 14
  • 99
  • 180
4
votes
1 answer

Use Boost Preprocessor to Parse sequence of elements

I have a macro defined which is #define TYPES (height,int,10)(width,int,20) How to expand this macro using Boost Preprocessor something like this? int height = 10; int width = 20; at most i am able to get is height,int,10 and width,int,20 as…
bhawesh
  • 1,220
  • 2
  • 18
  • 55
4
votes
1 answer

C Preprocessor, Macro "Overloading"

I'm trying to do some kind of Macro "Overloading", so that MACRO(something), gets expanded differently than MACRO(something, else). Using a snippet I got from here (I'm not sure if it's 100% portable) and some functions from the Boost PP Library, I…
almosnow
  • 2,546
  • 4
  • 23
  • 42
4
votes
2 answers

How to force processor to use result of expression before pasting

My code is #define PASTE__(a, b) a##b #define PASTE_(a, b) PASTE__(a, b) #define PASTE(a, b) PASTE_(a, b) int main() { PASTE(1, (1+3)/4); return 0; } I would LIKE to have the result be int main() { 11; return 0; } Compilable…
Bob
  • 4,128
  • 4
  • 22
  • 75
4
votes
2 answers

Boost preprocessor program won't compile after change from Boost 1.55 to 1.57

I've written some preprocessor directives to generate functions for a class. With Boost 1.55 everything works fine. When I try to change to Boost 1.57 I've got some strange compile errors. The program is: #include #include…
Franz
  • 93
  • 5
4
votes
1 answer

Iteration limit in Boost Preprocessor

I am writing a unit test using the Boost::Test framework for a comparison function. For each test case I create a series of input elements and compare them pairwise to check the return value of the comparison function for each pair. I can either…
petersohn
  • 10,129
  • 11
  • 54
  • 87
4
votes
1 answer

Boost-pp: how to determine if a macro parameter is a tuple

A tuple is a comma-separated list enclosed by parens, e.g. () (,) (thing,) (2,3) If I have #define ISTUPLE(x) \\... I'd like something like ISTUPLE(nope) to resolve to 0 and ISTUPLE((yep)) to resolve to 1. [FWIW, I have _RTFM_'d a plenty.]
Clay Bridges
  • 10,746
  • 10
  • 62
  • 110
4
votes
1 answer

Creating list of stringized macro arguments with variadics and late expansions

I have the following problem - given variable number of macro arguments argX to create a list of stringized arguments #argX Example: LIST(A, B) -> "A", "B" LIST(A, B, C) -> "A", "B", "C" I'm using Boost, so the above macro is not too difficult to…
4
votes
1 answer

BOOST_PP_REPEAT with array

I have struct like : struct E1 { typedef boost::tuple< boost::optional< N::type_A >, // N - namespace boost::optional< N::type_B >, ................... boost::optional< N::type_X > //arbitrary number of, maximal is 7 …
Khurshid Normuradov
  • 1,506
  • 12
  • 20
4
votes
1 answer

C++11 how to proxy class function having only its name and parent class?

I wonder if it is possible using boost::mpl/preprocessor or some noce C++11 features to create function proxy from class type and function name. Say we had: inline void set_email(const ::std::string& value); inline void set_email(const char*…
myWallJSON
  • 8,264
  • 17
  • 72
  • 139
3
votes
2 answers

Is Boost.Preprocessor self-contained?

I'm thinking about using Boost.Preprocessor in some project, but I don't want to make the entire Boost library a dependency. Can I just copy it alone and get away with this? Otherwise, what are its dependencies?
uj2
  • 2,095
  • 2
  • 20
  • 30
3
votes
3 answers

Why gcc breaks in recursively expanding macros

Good day, I've faced with a strange problem while compiling very simple C++ program which leverages recursive macros expansion: #define FINAL(a1, a2, a3) const char *p = "final values are: " #a1 " " #a2 " " #a3; #define SPLIT(a1, a2) a1, a2 #define…
3
votes
1 answer

Generate a set of tagged and indexed specializations of a class template using Boost.Preprocessor

There is a need to create a macro to generate a set of overloadings of a struct specialized by tag and index. I tried the following: #include template< typename /*tag*/, int /*index*/ > struct S; #define…
3
votes
4 answers

C preprocessor macros: check if token was declared

This is for the C preprocessor experts: How can I declare an enum with a list of some identifiers and later during the switch-statement check if an identifier was included in the list? Example of what I need: typedef enum { e1, e2, e3, e4, e5, e6 }…
Thomas
  • 961
  • 1
  • 9
  • 20
1
2
3
10 11