我从今天起就遭遇了这次本机崩溃。据报道只有Android 6.0。使用stacktrace:
#include <initializer_list>
#include <iterator>
void f(std::initializer_list<int> il) {}
int main()
{
int parameters[4]{1, 2, 3, 4};
auto test1 = {parameters}; // parameters decays into an int*, so we get an initializer_list of int*s (single pointer in this case)
// named parameter causes problems
//f(parameters); // doesn't compile, can't convert array to initializer_list
//f({parameters}); // doesn't compile, initializer_list types are different
//f({std::begin(parameters), std::end(parameters)}); // doesn't compile, considered as list of pointers
// this works on MSVC, but is probably not standard C++
std::initializer_list<int> test2(std::begin(parameters), std::end(parameters)); // use constructor that accepts iterators
f(std::initializer_list<int>(std::begin(parameters), std::end(parameters))); // ok
f(test2); // ok
f({1, 2, 3, 4}); // ok, can construct parameter with this initializer
f({}); // ok, for the same reason as above
}
对此的任何建议都会有所帮助,因为我无法理解这一点或重现此崩溃。
答案 0 :(得分:1)