boost-preprocessor

How to use boost preprocessor to generate accessors?

点点圈 提交于 2019-11-26 14:18:08
问题 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. 回答1: Disclaimer:You should probably wait in case a better answer appears even if you are satisfied with this answer, because I'm

Is the C99 preprocessor Turing complete?

感情迁移 提交于 2019-11-26 08:00:30
问题 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? 回答1: 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:

Construct path for #include directive with macro

心已入冬 提交于 2019-11-26 07:46:07
问题 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: