I have the following code that attempts to use uniform initialization of a std::array in the constructor:
#include <iostream>
#include <array>
struct test_type_t {
test_type_t(const std::array<double, 2> & arr) : arr_{arr} {}
void print() {
std::cout << "size: " << arr_.size() << std::endl;
} // print
std::array<double, 2> arr_;
};
int main(int argc, char ** argv) {
std::array<double, 2> array{ 1.0, 2.0 };
test_type_t test{array};
test.print();
return 0;
} // main
This code compiles with g++ and clang++. However, Intel icpc (17.0.0 20160721) fails with:
icpc -g -O2 -std=c++14 -I. -c main.cc -o main.o
main.cc(9): error: no suitable conversion function from "const
std::array<double, 2UL>" to "double" exists
test_type_t(const std::array<double, 2> & arr) : arr_{arr} {}
^
My question is, "Is this a bug in Intel icpc, or are g++ and clang++ being too permissive?"
Intel icpc compiles the code if I change 'arr_{arr}' to 'arr_(arr)' in the constructor.
Aucun commentaire:
Enregistrer un commentaire