C++11 Implicit conversion from initialization list to array parameter
问题 In C++11, is it possible to do something similar to the following? template<typename T, size_t N> void foo(array<T, N> src) { ... } ... foo({1, 2, 3}) I'm currently running GCC 4.8. 回答1: Yes , I managed to get the following work (since you allow something similar ): template<typename T, size_t N> void foo(array<T, N> src) { ... } ... foo('a', 'b'); foo(1, 2, 3); Here is how: #include <array> #include <iostream> #include <utility> using namespace std; template<typename T, unsigned long N> void