Why does the number of elements in a initializer list cause an ambiguous call error?

前端 未结 3 1839
野性不改
野性不改 2020-12-29 18:02

Why are the first two calls to doSomething OK by the compiler, but using two elements in the list causes an ambiguous call?

#include 

        
3条回答
  •  误落风尘
    2020-12-29 18:06

    "hello" and "stack" both decay to const char * which satisfies the InputIterator concept. This allow's them to match std::vector's constructor #4.

    If you pass std::string objects the ambiguity is resolved.

提交回复
热议问题