constexpr , , , ()
int a1 = 5;
std::array<int, a1> arr1;
const int a2 = 5;
std::array<int, a2> arr2;
int f1() { return 3; }
std::array<int, f1()> arr3;
constexpr int f2() { return 3; }
std::array<int, f2()> arr4;
:
constexpr int f3() { return f1() + 1; }
constexpr int f4() { return f2() + 1; }
std::array<int, f4()> arr5;
: ( ), , ( ).
constexpr std::string f5() { return "hello"; }
constexpr const std::string& f6() {
static const std::string s = "hello";
return s;
}
template<const std::string& s> SomeClass { ... };
SomeClass<f6()> someObject;