For templates, I would prefer something like:
template<typename T> void bar() { static_assert(not std::is_same_v<T, int>, "T cannot be 'int', this is not supported"); }
because it displays an error message to explain why bar<int> is not accepted.
bar<int>
Right, meaningful error messages are a great treasure in C++! Especially with templates.
A colleague has just me how to do this with concepts from C++20. I will have to write an article about every possibilities we have :D
Yeah, it's something I have in mind for the next few months, to experiment with concepts. They seem really interesting.
Why libstdc++ authors don't use this? It would be incredible to receive a readable error message
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink.
Hide child comments as well
Confirm
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
For templates, I would prefer something like:
because it displays an error message to explain why
bar<int>
is not accepted.Right, meaningful error messages are a great treasure in C++! Especially with templates.
A colleague has just me how to do this with concepts from C++20. I will have to write an article about every possibilities we have :D
Yeah, it's something I have in mind for the next few months, to experiment with concepts. They seem really interesting.
Why libstdc++ authors don't use this? It would be incredible to receive a readable error message