Good video Vittorio!
The following is a brief description of the difference between an ad int
const
and constexpr
:
int get_int();
template <int N>
struct test {};
const int w = get_int();
const int x = 5;
constexpr int y = get_int();
constexpr int z = 6;
int
main()
{
test<w> tw;
test<x> tx;
test<y> ty;
test<z> tz;
}
constexpr
, , , . const
, , , .
const int
, ( , const int
), , const int
.
constexpr int
, , , , . , .
<Disclaimer>
Kerrek SB , " " . , . , " " " ", - , 5.19 " " [expr.const] .
, ([basic.start.init]/p2).
, , , , , , , .
</Disclaimer>