3 ms·
It should be noted that at least some cases which previously required template meta programming can now be done in a more natural style with constexpr. A conste
by vinkelhake 13y ago
It should be noted that at least some cases which previously required template meta programming can now be done in a more natural style with constexpr. A constexpr function can be evaluated at compile time, this means that its return value can be used in places that require a compile time constant.
constexpr functions where quite restrictive in C++11. They could pretty much only contain a single expression and a return. C++14 significantly relaxes these restrictions.
http://en.wikipedia.org/wiki/C%2B%2B14#Relaxed_constexpr_restrictions http://en.wikipedia.org/wiki/C%2B%2B14#Relaxed_constexpr_res...
Type-level meta programming is still confined to using templates though...
- hun-nemethpeter 13y agoI tried to make a proposal for a more natural meta programming: https://github.com/hun-nemethpeter/cpp-reflector-mini/blob/master/Proposal.md https://github.com/hun-nemethpeter/cpp-reflector-mini/blob/m...
- pcwalton 13y agoconstexpr doesn't really help for logic programming though, which is what this post is using template specialization to do. You can't ask for the answer to Russell's paradox using constexpr (which is, IMHO, a good thing).
- pfultz2 13y ago> Type-level meta programming is still confined to using templates though... Which there is less of need for this, since we have better type deduction in C++11 and 14 as well.
- zem 13y agoD has very good support for this. here's a quick string templating function i wrote, for instance: https://gist.github.com/martindemello/2686640 https://gist.github.com/martindemello/2686640 it calls a function at compile time to expand placeholders, and then compiles the generated string via the mixin() statement and carries on with the code. far more pleasant than c++.