C++ Logo


Advanced search

Re: Static Failure - Custom Compile-Time Errors

From: Jason McKesson <jmckesson_at_[hidden]>
Date: Sat, 19 Jun 2021 00:50:05 -0400
I think you need to find a better example, as I can write a superior
version with existing C++20 tools:

template<std::integral T>
  requires is_one_of<T, std::uint8_t, std::uint64_t>
void my_func(T param)

This has the advantage of making it clear *in the interface* of the
function what is required, rather than being an implementation detail
that might not be seen by the user.

Can you provide use cases that aren't better written as concepts?

Received on 2021-06-18 23:50:21