1974 shaares
6 private links
6 private links
5 results
tagged
metaprog
Implementing f() to make the following snippet compile without the static_assert being fired looks impossible, doesn't it?
// <insert solution here>
int main () {
constexpr int a = f ();
constexpr int b = f ();
static_assert (a != b, "fail");
}
A dependent type is a type that has a dependency on a value. It essentially is way to encode values into the type, that is, every value has a unique type. Non-type template parameters in C++ allow this. Also, std::integral_constant is good example of dependent typing.