1 // PR c++/65985 2 // { dg-do compile { target c++14 } } 3 4 #include <cassert> 5 6 class Angle 7 { 8 int degrees = 0; 9 invariant()10 constexpr auto invariant() const noexcept 11 { 12 return 0 <= degrees && degrees < 360; 13 } 14 15 public: Angle(int n)16 explicit constexpr Angle(int n) noexcept 17 : degrees{n % 360} 18 { 19 assert(invariant()); 20 } 21 auto()22 /* implicit */ constexpr operator auto() const noexcept 23 { 24 return degrees; 25 } 26 }; 27 main()28int main() 29 { 30 static_assert(Angle{360} == 0, ""); 31 } 32