Code: Select all
class Foo {
public:
...
static const std::vector _data;
< /code>
In der entsprechenden Quelldatei bevölkern ich die Daten ... < /p>
const std::vector
Foo::_data
{
std::make_tuple("One", 1),
std::make_tuple("Two", 2),
...
std::make_tuple("Many", 10)
};
aus
Code: Select all
/path/to/src/Foo.cpp:783:14: warning: initialization of '_data' with static storage duration may throw an exception that cannot be caught [cert-err58-cpp]
Foo::_data
^
/path/to/gcc-9.2.0/lib/gcc/x86_64-redhat-linux/9.2.0/../../../../include/c++/9.2.0/bits/stl_vector.h:622:7: note: possibly throwing constructor declared here
vector(initializer_list __l,
^
Bearbeiten: Hier ist der Code, für den ich mich entschieden habe. Keine Quelldateizusätze. Dies ist die Header -Datei ... < /p>
Code: Select all
static constexpr std::array _data {
{
{{"One", 1},
{"Two", 2},
...
{"Ten", 10}}
};