#include
#include
#include
#include
namespace Mynamespace
{
class IComponent {
virtual ~IComponent() = default;
};
}
namespace Mynamespace
{
class Input {
public:
Input();
~Input();
};
}
namespace Mynamespace
{
class Output {
public:
Output();
~Output();
};
}
namespace Mynamespace
{
class Factory {
private:
std::map Map;
public:
Factory();
void initializeMap();
}
void Mynamespace::Factory::initializeMap()
{
Map = {
{"input", [](){return std::make_unique();}},
{"output", [](){return std::make_unique();}}
};
}
сообщение об ошибке:
test.cpp:39:2: error: expected ‘;’ after class definition
39 | }
| ^
| ;
test.cpp: In member function ‘void Mynamespace::Factory::initializeMap()’:
test.cpp:46:5: error: no match for ‘operator=’ (operand types are ‘std::map’ and ‘
’)
46 | };
| ^
In file included from /usr/include/c++/13/map:63,
from test.cpp:4:
/usr/include/c++/13/bits/stl_map.h:331:7: note: candidate: ‘std::map& std:
331 | operator=(const map&) = default;
| ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:331:17: note: no known conversion for argument 1 from ‘
’ to ‘const std::map&’
331 | operator=(const map&) = default;
| ^~~~~~~~~~
/usr/include/c++/13/bits/stl_map.h:335:7: note: candidate: ‘std::map& std:
335 | operator=(map&&) = default;
| ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:335:17: note: no known conversion for argument 1 from ‘
’ to ‘std::map&&’
335 | operator=(map&&) = default;
| ^~~~~
/usr/include/c++/13/bits/stl_map.h:349:7: note: candidate: ‘std::map& std:
349 | operator=(initializer_list __l)
| ^~~~~~~~
/usr/include/c++/13/bits/stl_map.h:349:46: note: no known conversion for argument 1 from ‘
’ to ‘std::initializer_list’
349 | operator=(initializer_list __l)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
test.cpp: At global scope:
test.cpp:47:2: error: expected ‘}’ at end of input
47 | }
| ^
test.cpp:32:1: note: to match this ‘{’
32 | {
Подробнее здесь: https://stackoverflow.com/questions/798 ... -as-values
Мобильная версия