This code is valid with C ++ 14
using namespace std; struct Point { int x = 0; int y = 0; }; Point p2 {1, 1};
It compiles fine with clang ++ 7.0, it does not work with g ++ 4.9 in both cases I pass -std = C ++ 1y to the compiler.
In g ++, it works when I remove the default values โโfrom the structure definition.
g++ test_constexpr_ctor.cc --std=c++1y -o test test_constexpr_ctor.cc:7:15: error: no matching function for call to 'Point::Point(<brace-enclosed initializer list>)' Point p2 {1, 1}; ^ test_constexpr_ctor.cc:7:15: note: candidates are: test_constexpr_ctor.cc:1:8: note: constexpr Point::Point() struct Point ^ test_constexpr_ctor.cc:1:8: note: candidate expects 0 arguments, 2 provided test_constexpr_ctor.cc:1:8: note: constexpr Point::Point(const Point&) test_constexpr_ctor.cc:1:8: note: candidate expects 1 argument, 2 provided test_constexpr_ctor.cc:1:8: note: constexpr Point::Point(Point&&) test_constexpr_ctor.cc:1:8: note: candidate expects 1 argument, 2 provided
source share