[Bug c++/101137] std::conjunction result error

redi at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jun 21 13:33:22 GMT 2021


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101137

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Jonathan Wakely from comment #3)
> template<typename T>
> concept SignedIntegralRef1
>   = std::is_lvalue_reference_v<T> && SignedIntegral1<T>;

Oops, that should be
std::is_lvalue_reference_v<T> && SignedIntegral1<std::remove_reference_t<T>>
(which is easy to spot when you break the wall of text into pieces).

It's irrelevant here anyway, because you can never have a type like
deque<int&>, so it would make a lot more sense for your code to have separate
concepts as above, and then for the the concepts like Container you only need
to use the SignedIntegral1 concept, because the container's value type can't be
a reference.

N.B. defining traits just to use as arguments to std::conjunction just to
define concepts is ... peculiar.

Why not just define the concepts directly? It will compile much faster.

template<typename T>
concept ContainerOfSignedIntegral
  = Container<T> && SignedIntegral<typename T::value_type>;

template<typename T0, typename T1>
concept SignedIntegralConvertCopy1
  = ContainerOfSignedIntegral<T0> && !ForwardList<T0>
    && ContainerOfSignedIntegral<T1>
    && (!std::same_as<typename T1::value_type, typename T2::value_type>);

template<typename T0, typename... T1>
concept SignedIntegralConvertCopy = (SignedIntegralConvertCopy1<T0, T1> &&
...);


More information about the Gcc-bugs mailing list