+ 3

C++: concepts in C++ STL not available when running C++ on SoloLearn

I tried running a program using the concept feature of C++20 on SoloLearn. It worked which means that SoloLearn is compiling the code using C++20. But even though the code is compiling using C++20, the concepts in STL (like same_as, integral) are not available. See: https://code.sololearn.com/cvK14aFiPsYD/?ref=app It works here http://coliru.stacked-crooked.com/a/685567040df7b2c7 The strange thing is that both SL and Coliru use GCC. So why can I use the STL concepts on Coliru but not on SoloLearn?

24th Apr 2021, 8:00 AM
XXX
XXX - avatar
5 Answers
+ 2
Yes, but the underlying functionality apparently has been in GCC for quite a while as a technical specification: https://en.cppreference.com/w/cpp/experimental/constraints Maybe that's why the keywords and syntax work, but not the header. It's a bit weird that not everything works, for example compound requirements nonetheless cause a compilation error. But other than that, I don't really have an explanation.
24th Apr 2021, 9:56 AM
Shadow
Shadow - avatar
+ 2
Actually, it seems SL does not compile with C++20: https://code.sololearn.com/c18k2t3Mzvd5/?ref=app This works on my local machine with GCC 10.2.0, and the same goes for many new headers like <bit>.
24th Apr 2021, 9:03 AM
Shadow
Shadow - avatar
+ 2
Shadow But aren't concepts a feature of C++20? We can use concepts on SoloLearn.
24th Apr 2021, 9:50 AM
XXX
XXX - avatar
+ 2
Shadow that makes sense. Thanks.
24th Apr 2021, 10:03 AM
XXX
XXX - avatar
+ 1
@Martin Taylor You're right. I had thought that gcc was using C++20 because the 'concept' keyword and type constraints worked which are features of C++20.
24th Apr 2021, 8:33 PM
XXX
XXX - avatar