没有重载函数需要 2 个参数错误,并带有 boost::assign::list_of
No overloaded function takes 2 arguments error with boost::assign::list_of
为什么会出现错误:Test::Test: no overloaded function takes 2 arguments
class Test
{
public:
Test(const std::vector<int>&)
{
}
};
Test test(boost::assign::list_of(4));
boost::assign::list_of 的实现要求容器类型(在本例中为 Test 类)具有双参数构造函数,该构造函数采用第一个和最后一个迭代器(也称为 range)来初始化容器。
具体来说,错误来自下面的行,返回容器在 boost::assign_detail::转换器类的转换方法中:
template< class Container >
Container convert( const Container*, default_type_tag ) const
{
return Container( begin(), end() );
}
hmjd 的解决方法成功的原因是 std::vector 有一个构造函数需要两个迭代器。
相关文章:
- 当为可变性配置时,boost::heap::d_ary_heap 保留的额外 std::list 的目的是什么?
- 如何将值插入到 c++ boost::multiindex 集合的特定索引中,就像在 std::list 中一样
- 在C++中标记化"Braced Initializer List"样式字符串(使用 Boost?
- Boost Python使用std :: list展示C 类
- boost.spirit x3 move_to and list ast member
- boost::instrusive::list 带有自动取消链接钩子:我可以使用列表中的值来确定列表是否只有一个元素
- 如何在迭代boost :: Intrusive :: list时擦除
- 从C++缓冲区到python::boost::list
- 将 std::list<boost::any> 作为函数的参数传递
- 如何将 boost python list 转换为 PyObject
- 使用boost-ptre将std::list序列化为json
- 在 boost::unordered_map 的 std::string 和 std::list 中提供线程安全,同时对
- 使用 boost 将 std::list 传递给构造函数,list_of不编译
- 如何使用给定数量的元素初始化boost::python::list
- 如何从 boost::p ython::list 中提取值到C++
- 提取并转换 boost::p ython::list 的列表元素
- 如何在mpl::list中声明boost递归变体
- Boost mpl::list变量序列化check_const_loading()编译错误
- boost::python传递对python::list的引用
- 如何将 std::vector<boost::shared_ptr<T>> 复制到 std::list<T>