Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to test if a type exists in a concept?

How can I test if a member type exists in a concept template argument, i.e. for typename Container, test for Container::reverse_iterator ? What's the proper requires-clause ?

like image 664
Bonita Montero Avatar asked Mar 02 '23 11:03

Bonita Montero


1 Answers

We do this with the aptly named type requirement:

template<class Container>
concept has_reverse_iterator = requires {
    typename Container::reverse_iterator;
};
like image 172
StoryTeller - Unslander Monica Avatar answered Mar 12 '23 18:03

StoryTeller - Unslander Monica