'Why does the std::sentinel_for concept require default constructability?

Why does the new std::sentinel_for concept require that the sentinel type is default_initializable (via semiregular)? Doesn't that rule out a large class of useful sentinel types where default construction doesn't make any sense?

Example:

//Iterate over a string until given character or '\0' is found
class char_sentinel
{
public:
    char_sentinel(char end) :
        end_character(end)
    { }

   friend bool operator==(const char* lhs, char_sentinel rhs)
   {
       return (*lhs == '\0') || (*lhs == rhs.end_character);
   }

   friend bool operator!=(const char* lhs, char_sentinel rhs) { ... }
   friend bool operator==(char_sentinel lhs, const char* rhs) { ... }
   friend bool operator!=(char_sentinel lhs, const char* rhs) { ... }

private:
    char end_character; 
};

I know I can add a default constructor which initializes to '\0' but what if I consider that as misuse of the structure and want to discourage that?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source