Reputation: 2105
Suppose I have 3 concepts:
ostreamable
istreamable
iostreamable
Where the definitions:
template <typename T>
concept ostreamable = requires (std::ostream& os, T arg) {
{os << arg} -> std::convertible_to<std::ostream&>;
};
template <typename T>
concept istreamable = requires (std::istream& is, T& arg) {
{is >> arg} -> std::convertible_to<std::istream&>;
};
template <typename T>
concept iostreamable = ostreamable<T> && istreamable<T>;
Application:
iostreamable auto var1 = {4, 5, 10, 10}; // no error, but unexpected.
iostreamable auto var2 = 3.232; // no error, expected
iostreamable auto var3 = std::bitset<4>{0b1001}; // no error, expected
iostreamable auto var4 = std::vector{4, 10, 3, 10}; // compilation error, expected
When I use var1
with the requirements of said concept iostreamable
such as applying with operator<<
or operator>>
, I expectedly got the verbose compilation error.
Upvotes: 1
Views: 53
Reputation: 96951
This appears to be a GCC bug.
Clang & MSVC reject your code.
Upvotes: 1