Linked Questions

17 questions linked to/from constexpr overloading
5 votes
0 answers
117 views

constexpr void X() { /* code, that can be executed at compiletime */ } void X() { /* code, that does the same as above, but is optimized for runtime, eg. including caching, assembler code, ... ...
user avatar
42 votes
5 answers
8k views

Is it possible to produce a compile-time boolean value based on whether or not a C++11 expression is a constant expression (i.e. constexpr) in C++11? A few questions on SO relate to this, but I don't ...
30 votes
1 answer
15k views

Consider a simple int Wrapper class with overloaded multiplication operator*= and operator*. For "old-style" operator-overloading, one can define operator* in terms of operator*=, and there are even ...
11 votes
4 answers
1k views

I'm using gcc 4.6.1 and am getting some interesting behavior involving calling a constexpr function. This program runs just fine and straight away prints out 12200160415121876738. #include <...
Omnifarious's user avatar
  • 56.5k
14 votes
3 answers
6k views

I previously asked about function overloading based on whether the arguments are constexpr. I'm trying to work around the disappointing answer to that question to make a smarter assert function. This ...
11 votes
1 answer
2k views

Why doesn't this compile: Could there be a problem with a string as a return type? constexpr std::string fnc() { return std::string("Yaba"); }
18 votes
2 answers
4k views

Can I detect at compile time whether "function arguments"1 are compile-time constants? For example a function print(int i) that can print "constant 5" if called as print(5) but "non-constant 5" if ...
17 votes
2 answers
774 views

Is there a way to achieve different behaviour of a constexpr function in the compilation phase and at runtime? Consider the following example (using a theoretical feature from D: static if): ...
nonsensation's user avatar
  • 3,737
14 votes
2 answers
4k views

Most C++ compilers support SIMD(SSE/AVX) instructions with intrisics like _mm_cmpeq_epi32 My problem with this is that this function is not marked as constexpr, although "semantically" there is no ...
25 votes
1 answer
759 views

I tried to implement a value template similar to std::is_constructible with the exception to only be true when the type is copiable in a constexpr environment (i.e. its copy constructor is constexpr ...
8 votes
1 answer
829 views

The wording of [expr.unary.noexcept] changed in C++17. Previously (n4140, 5.3.7 noexcept operator [expr.unary.noexcept]), my emphasis: The result of the noexcept operator is false if in a ...
2 votes
3 answers
1k views

Is there a way in c++ to get a different overload called based on the runtime/compile time constness of an input? My version(12) of MSVC can't do this using constexpr. Reading c++ documentation, I am ...
johnnycrash's user avatar
  • 5,382
11 votes
1 answer
263 views

I want to implement my_static_assert that slightly differs from c++17 single-parametric static_assert: if condition inside my_static_assert is not known at compile time, it should pass. The second ...
user avatar
4 votes
3 answers
300 views

Is there a way to overload a function in a way to distinguish between the argument being evaluable at compile time or at runtime only? Suppose I have the following function: std::string lookup(int ...
4 votes
2 answers
903 views

Suppose I have the function: template<size_t N> void foo(std::integral_constant<size_t,N>); Right now to use it I do this: constexpr size_t myNum = 12; foo(std::integral_constant<...

15 30 50 per page
1
2