error: call of overloaded 'Base(
)' is ambiguous
The detailed Сообщение об ошибке и код следующие: < /p>
Код: Выделить всё
: In function 'int main()':
:33:23: error: call of overloaded 'Base(
)' is ambiguous
33 | Base b({a.shape()});
| ^
:24:5: note: candidate: 'constexpr Base::Base(Base&&)'
24 | Base(Base &&) = default;
| ^~~~
:23:5: note: candidate: 'constexpr Base::Base(const Base&)'
23 | Base(const Base &) = default;
| ^~~~
:22:14: note: candidate: 'Base::Base(const Layout&)'
22 | explicit Base(const Layout &layout) : m_layout(layout) {}
| ^~~~
Compiler returned: 1
< /code>
#include
#include
#include
using IntTuple = std::vector;
class Layout {
IntTuple m_shape;
public:
Layout(const IntTuple &shape) : m_shape(shape) {}
IntTuple shape() {
return m_shape;
}
};
class Base {
Layout m_layout;
public:
explicit Base(const Layout &layout) : m_layout(layout) {}
Base(const Base &) = default;
Base(Base &&) = default;
IntTuple shape() {
return m_layout.shape();
}
};
int main() {
Base a(IntTuple{1, 2, 3});
Base b({a.shape()}); // error
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... st-as-a-co