python (65.2k questions)
javascript (44.3k questions)
reactjs (22.7k questions)
java (20.8k questions)
c# (17.4k questions)
html (16.3k questions)
r (13.7k questions)
android (13k questions)
Cannot use template function type in constant context with MSVC 1930+ (Visual Studio 2022)
When I have a function template like this:
template<class T>
T func(T bar) {
return bar;
}
I cannot use its instantiation in constant context with the latest MSVC compiler:
constexpr bool b...

Fido
Votes: 0
Answers: 0
Conditional inclusion: integral constant expression is unlimited?
Per C++11 (and newer) this code is valid:
#if 1.0 > 2.0 ? 1 : 0
#endif
However, most (if not all) C++ compilers reject it:
$ echo "#if 1.0 > 2.0 ? 1 : 0" | g++ -xc++ - -std=c++11 -ped...
pmor
Votes: 0
Answers: 1
Conditional inclusion: integer constant expression is limited?
C11, 6.10.1 Conditional inclusion, Constraints, 1 (emphasis added):
The expression that controls conditional inclusion shall be an integer constant expression
C11, 6.6 Constant expressions, 6 (empha...
pmor
Votes: 0
Answers: 1
Why exactly using of a floating-point arithmetic in an integer constant expression is invalid?
In C11 (and later) integer constant expression shall only have operands that are, in particular:
floating constants that are the immediate operands of casts
The following code:
int a[ A > B ? 16 ...
pmor
Votes: 0
Answers: 2