GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::unreachable_sentinel_t,std::unreachable_sentinel(3) C++ Standard Libary std::unreachable_sentinel_t,std::unreachable_sentinel(3)

std::unreachable_sentinel_t,std::unreachable_sentinel - std::unreachable_sentinel_t,std::unreachable_sentinel


Defined in header <iterator>
struct unreachable_sentinel_t; (1) (since C++20)
inline constexpr unreachable_sentinel_t unreachable_sentinel{}; (2) (since C++20)


1) unreachable_sentinel_t is an empty class type that can be used to denote the
“upper bound” of an unbounded interval.
2) unreachable_sentinel is a constant of type unreachable_sentinel_t.


operator== compares an unreachable_sentinel_t with a value of any
(C++20) weakly_incrementable type
(function template)

operator==(std::unreachable_sentinel_t)


template<std::weakly_incrementable I>


friend constexpr bool operator==( unreachable_sentinel_t, const I& ) (since C++20)
noexcept


{ return false; }


unreachable_sentinel_t can be compared with any weakly_incrementable type and the
result is always false.


This function template is not visible to ordinary unqualified or qualified lookup,
and can only be found by argument-dependent lookup when std::unreachable_sentinel_t
is an associated class of the arguments.

// Run this code


#include <cstddef>
#include <iterator>
#include <algorithm>
#include <iostream>


template<class CharT>
constexpr std::size_t strlen(const CharT *s)
{
return std::ranges::find(s, std::unreachable_sentinel, CharT{}) - s;
}


template<class CharT>
constexpr std::size_t pos(const CharT *haystack, const CharT *needle)
{
// search(begin, unreachable_sentinel) is usually more efficient than
// search(begin, end) due to one less comparison per cycle.
// But "needle" MUST BE in the "haystack", otherwise the call is UB,
// which is a compile-time error in constexpr context.
return std::ranges::search(
haystack, std::unreachable_sentinel,
needle, needle + strlen(needle)
).begin() - haystack;
}


int main()
{
static_assert(
strlen("The quick brown fox jumps over the lazy dog.") == 44
);


static_assert(
pos("const short int", "short") == 6
);


// static_assert(pos("long int", "float")); // compile-time error
}


ranges::iota_view a view consisting of a sequence generated by repeatedly
views::iota incrementing an initial value
(C++20) (class template) (customization point object)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.