Click here to Skip to main content
15,886,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
the C++ code below compiles w/o error on VS however Clang reports an error . which is correct ?
C++
template<typename T> requires concept_which_does_not_exist<T>
void foo(T) {}
[update]
presumably the correct answer is this is fact an error i.e. CLang is correct in reporting an error and VS is incorrect in not reporting an error as this is what chatGBT has informed . case closed .

What I have tried:

i have tried and succeeded in not reading the C++ specification as that is a tangle of weeds i do not wish to jump into . i have not searched internet as i expect this is rather archaic .
Posted
Updated 30-Mar-23 14:58pm
v6

1 solution

Yes, there is an error. main is supposed to return an integer value.

The requires statement looks OK as far as I can tell. Here is more info on the keyword : C++20 Concepts - a Quick Introduction - C++ Stories[^]
 
Share this answer
 
Comments
BernardIE5317 28-Mar-23 1:39am    
thank you for pointing out the error . i removed main as i had left it in prior only as a nicety . still Clang reports an error for a reference to a concept which does not exist while VS does not but only if no code attempts to execute the function w/ the non-existent requires concept . as for concepts in general i have some familiarity with them as i utilize them w/ some regularity and success . -Best

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900