Compiling with -std=c++14 the following code:
#include <memory>
class A
{
public:
static constexpr int c = 0;
std::shared_ptr<int> b;
A() {
b = std::make_shared<int> (c);
}
};
int main () {
A a;
return 0;
}
Gives a linker error "undefined reference to `A::c'", while using "A::c" in other contexts that are not "make_shared", this error doesn't occur. In particular, the following code compiles and works correctly:
class A
{
public:
static constexpr int c = 0;
std::shared_ptr<int> b;
A() {
int cc = c;
b = std::make_shared<int> (cc);
}
};