Trying to initialize a static map. From other questions I've gathered that it must be done outside of the header file, and in c++11 can be done with uniform initialization. But when I try to use another static member, I get problems:
foo.h:
#include <map>
class TestSuite {
static constexpr int x = 3;
static std::map<int, int> v;
};
foo.cpp:
#include "foo.h"
std::map<int, int> TestSuite::v = {{x, 5}};
int main() {
TestSuite t;
}
Then I get the error
In function `__static_initialization_and_destruction_0(int, int)':
foo.cpp:(.text+0x4b): undefined reference to `TestSuite::x'
collect2: error: ld returned 1 exit status