Hi,

you can emulate C++17 inline variables in C++11 with either of the two ways:

1) via a template helper
template <typename = void>
struct Helper
{
    static constexpr unsigned value[4] = {1, 2, 3, 4};
};

template <typename T>
constexpr unsigned Helper<T>::value[4];

static constexpr auto& arr = Helper<>::value;

2) extern constexpr + weak attribute
[[gnu::weak]] extern constexpr unsigned arr[] = {1, 2, 3, 4};

Regards,
Maciej

Reply via email to