Consider the following code:
class Test {
public:
static const int VALUE = 100;
};
std::tuple<int> foo(std::tuple<int> value) {
return value;
}
int main()
{
auto t = std::make_tuple(Test::VALUE); // This compiles fine
auto t1 = foo(std::make_tuple(Test::VALUE)); // undefined reference to `Test::VALUE' linker error
}
According to the other question (What does it mean to "ODR-use" something?) and the answer:
In plain word, odr-used means something(variable or function) is used in a context where the definition of it must be present.
In the first case (variable t
) the variable VALUE
is not odr-used because only it' value is needed. But in the second case why the code won't compile? If I would pass t
instead of passed rvalue(?) the code would compile fine. How the second case differs from the first and why VALUE
is odr-used here?