I am experimenting the possibility of using concepts introduced in C++20 as static interfaces. So far, I am doing well except that I am unable to figure out a way to provide a "default implementation" for a concept.
For example, I have a concept named ByteBuffer, and it is stated like this:
template <typename T>
concept ByteBuffer = requires (T t) {
{ t.read_byte() } noexcept -> std::convertible_to<uint8_t>;
{ t.has_byte() } noexcept -> std::same_as<bool>;
/* default implementation for `t.read_until(...)`? */
};
I should be able to, logically, provide a default implementation for t.read_until(...) (parameters omitted), and allow concrete implementations to override the default one. Is there a way? How can I do it?
If this is not possible, I think it is reasonable to add such an ability.
Currently, I have to resort to the CRTP to provide a facade class, and I think it more redundant than I could conceive.