Wandbox
SettingsLog
SettingsLog
Language
GitHubLogin
Ran/Viewed Log

Author

anonymous

over 2 years ago

Language

C++

Compiler

gcc 12.1.0

Options
Warnings
Don't Use Boost
C++2a
-pedantic-errors

Author

anonymous

over 2 years ago

$ g++ prog.cc -Wall -Wextra -std=c++2a -pedantic-errors
prog.cc: In function 'int main()':
prog.cc:15:11: error: no matching function for call to 'my_abs(long unsigned int)'
   15 |     my_abs(42ul);
      |     ~~~~~~^~~~~~
prog.cc:7:6: note: candidate: 'template<class T>  requires (is_same_v<T, int>) || (is_same_v<T, float>) || (is_same_v<T, double>) auto my_abs(T)'
    7 | auto my_abs(T v) {
      |      ^~~~~~
prog.cc:7:6: note:   template argument deduction/substitution failed:
prog.cc:7:6: note: constraints not satisfied
prog.cc: In substitution of 'template<class T>  requires (is_same_v<T, int>) || (is_same_v<T, float>) || (is_same_v<T, double>) auto my_abs(T) [with T = long unsigned int]':
prog.cc:15:11:   required from here
prog.cc:7:6:   required by the constraints of 'template<class T>  requires (is_same_v<T, int>) || (is_same_v<T, float>) || (is_same_v<T, double>) auto my_abs(T)'
prog.cc:6:5: note: no operand of the disjunction is satisfied
    4 | requires (std::is_same_v<T, int>
      |          ~~~~~~~~~~~~~~~~~~~~~~~
    5 |     || std::is_same_v<T, float>
      |     ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    6 |     || std::is_same_v<T, double>)
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: note: set '-fconcepts-diagnostics-depth=' to at least 2 for more detail
Exit Code:
1