i tried to test some new features of C++ 11
but how come Visual Studio doesn't support constexpr?

i tried this simple function but it won't compile

constexpr int multiply(int x, int y)
        return x * y;

Because Microsoft couldn't reach full conformance in time and they created their own priority list of features (which includes C++14 features) based on what they believe customers want most.

hmmm thanks

For future reference here's the article on the c++11 features in Visual Studio 2013

From what the guys over at Clang and GCC have said, the constexpr feature is actually one of the hardest features to implement from C++11. I think it's because it actually constitutes (another) compile-time Turing complete language on top of C++.

Thanks vijayan121 it worked.
i don't know how important is constexpr yet, should i use GCC instead of VS?

I don't think that constexpr is used that much yet. And as far as standard libraries or Boost libraries, they will only use constexpr if it is supported by the compiler they are being used with. Such as the macros used by Boost.

Although it can probably be used in interesting ways, constexpr is mostly a syntactic sugar (for when you need a compile-time constant value, it avoids requiring C++03 template meta-programming) or about enabling some minor optimizations (pre-computing some expressions at compile-time). In other words, it is not really a necessary feature nor something that cannot be worked around when necessary. The point is, there probably aren't any important libraries for which constexpr is an absolute necessity, at least, not yet.

should i use GCC instead of VS?

I would say yes, but that's my opinion (I'm pretty sure vijayan121 would disagree). I think MSVC is a terrible compiler, period. Any other option is better. Also, if you feel adventurous, you could try the brand new, fresh out of the oven, Windows version and/or MSVC-compatible version of Clang.

Thanks Mike 2000 17

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.