boost-preprocessor

Boost Preprocessor library for generating a set of types based on a list of basic types e.g. PointI32, PointF32 etc. in C++/CLI

你离开我真会死。 提交于 2019-12-01 09:47:42
问题 I am trying to figure out how to use the Boost.Preprocessor library http://www.boost.org/doc/libs/release/libs/preprocessor to unfold a "generic" type for different specific types. Below I will ask this for a simple point class example. Given: struct Point##TYPE_SUFFIX_NAME { TYPE X; TYPE Y; // Other code }; I want to generate this type for different basic (POD) data types e.g.: PointF32, PointF64, PointI32 etc. where PointF32 would be: struct PointF32 { float X; float Y; }; That is, based on

Using Boost.Preprocessor to reduce this code repitition

吃可爱长大的小学妹 提交于 2019-12-01 06:09:24
问题 Consider the following code: template<typename T0> void send( const std::string& func, const T0& t0 ) { std::ostringstream s; s << func << ": " << t0; sendMessage( s.str() ); } template<typename T0, typename T1> void send( const std::string& func, const T0& t0, const T1& t1 ) { std::ostringstream s; s << func << ": " << t0 << "," << t1; sendMessage( s.str() ); } template<typename T0, typename T1, typename T2> void send( const std::string& func, const T0& t0, const T1& t1, const T2& t2 ) { std

D_WIN32_WINNT compiler warning with Boost

风流意气都作罢 提交于 2019-11-30 04:38:49
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 Definition. 1>Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example: 1>- add -D_WIN32_WINNT=0x0501 to the compiler command line; or 1>- add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions. I think you're really close to getting this to work. John Dibling gave three ways you could do this and it looks like you tried the

D_WIN32_WINNT compiler warning with Boost

非 Y 不嫁゛ 提交于 2019-11-29 02:29:31
问题 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 Definition. 1>Please define _WIN32_WINNT or _WIN32_WINDOWS appropriately. For example: 1>- add -D_WIN32_WINNT=0x0501 to the compiler command line; or 1>- add _WIN32_WINNT=0x0501 to your project's Preprocessor Definitions. 回答1: I think you're really

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

☆樱花仙子☆ 提交于 2019-11-28 02:56:23
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 know I could look at the output of the preprocessor to find the answer. I feel like having a way of doing this during compilation could be useful. If you are using Visual C++, you can use #pragma message : #include <boost/preprocessor/stringize.hpp> #pragma message("BOOST_VERSION=" BOOST_PP_STRINGIZE(BOOST_VERSION)) Edit: Thanks to LB for link

C Preprocessor, Macro “Overloading”

天涯浪子 提交于 2019-11-27 14:53:04
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 was able to make it work :D //THESE TWO COUNT THE NUMBER OF ARGUMENTS #define VA_NARGS_IMPL(_1, _2, _3, _4, _5, N, ...) N #define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1) //THIS ONE RETURNS THE PARAMETER AT POSITION _i FROM A LIST OF __VA_ARGS__ #define VA_ARG(_i, ...) BOOST_PP_ARRAY_ELEM(_i, (VA_NARGS(__VA_ARGS__), (__VA_ARGS__))) /

How to use boost preprocessor to generate accessors?

自古美人都是妖i 提交于 2019-11-27 08:47:51
For example class A { int m_x; float m_y; double m_z; int x() const {return m_x;} float y() const {return m_y;} double z() const {return m_z;} }; becomes like class A { MY_MACRO((int)(float)(double), (x)(y)(z)); }; Please use boost prerocessor sequence to do it because this macro will combine with other existing macros which already use boost preprocesor sequence. cv_and_he Disclaimer:You should probably wait in case a better answer appears even if you are satisfied with this answer, because I'm far from an expert and these may not be the best approaches. 1st approach: //two different

Construct path for #include directive with macro

我是研究僧i 提交于 2019-11-27 02:05:26
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 will expand to a something like this: #include "corefoundation/header.h" when the source is configured (in this case) for OSX So far all attempts have failed. I'm hoping someone out there has done this before? example of what does not work: #include <iostream> #include <boost/preprocessor.hpp> #define Dir directory/ #define File filename.h #define

Is the C99 preprocessor Turing complete?

有些话、适合烂在心里 提交于 2019-11-26 21:35:23
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? Here is an example of abusing the preprocessor to implement a Turing machine. Note that an external build script is needed to feed the preprocessor's output back into its input, so the preprocessor in and of itself isn't Turing complete. Still, it's an interesting project. From the description of the afore-linked project: the preprocessor is not Turing complete, at least not if the program is preprocessed only once. This is true

C Preprocessor, Macro “Overloading”

纵然是瞬间 提交于 2019-11-26 18:28:19
问题 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 was able to make it work :D //THESE TWO COUNT THE NUMBER OF ARGUMENTS #define VA_NARGS_IMPL(_1, _2, _3, _4, _5, N, ...) N #define VA_NARGS(...) VA_NARGS_IMPL(__VA_ARGS__, 5, 4, 3, 2, 1) //THIS ONE RETURNS THE PARAMETER AT POSITION _i FROM A LIST OF