Unfortunately you can not do something like this:
typedef constexpr int cint; And that is not the end of the world....just have to type out the extra 9 (10 if you include the space) characters every time you need to use constexpr.
But I have created a class and I want to only be able to create constexpr versions of this class (using a non constexpr version would not make any sense).
So my plan was to create the class with a non accessible namespace, and then create in my main namespace a constexpr typedef, like so:
namespace MainNameSpace{ namespace detail{ class MyClass{}; } typedef constexpr detail::MyClass MyClass; } Unfortunately I discovered that this cannot be done....is there any way to achieve a similar effect (with out using macros)?
constexprisn't part of the type system. It's part of the expression system, i.e. of the nature of values.using a non constexpr version would not make any senseHow does a constexpr version make sense? What do you expect it to do?constexprversion I was probably trying to use a normal string or I just forgot to type it out.....I am wondering if there is any way to avoid this mistake