template<typename KType, typename PType = std::less<KType>, typename AllocType = std::allocator<KType>> class MySet { public: typedef std::set<KType, PType, AllocType> set_type; typedef typename set_type::iterator iterator; typedef typename set_type::const_iterator const_iterator; MySet(std::initializer_list<KType> _Ilist): s(_Ilist) { } template <class... Args> iterator emplace_hint(const_iterator hint, Args&&... args) { return s.emplace_hint(hint, std::forward<Args>(args)...); } const_iterator cbegin() const { return s.cbegin(); } private: set_type s; }; //main MySet<int> x { 1, 2, 3 }; x.emplace_hint(x.cbegin(), 4); // OK x.emplace_hint(x.cbegin(), 5, 6, 7); // выдаёт ошибку 

Error C2440 'initializing': cannot convert from 'initializer list' to 'int'

  • why no hits - GeorgiyRyazanov

1 answer 1

All right, emplace (like emplace_hint ) creates a container object from the passed arguments. You have int s in the container, so it tries to create an int , but it cannot create an int , because you pass too many arguments.