| 
    cxxomfort
    rel.20210622
    
   Simple backports for C++ - http://ryan.gulix.cl/fossil.cgi/cxxomfort/ 
   | 
 
An object representing a reference or slice of a contiguous area of memory of type T . More...
Public Types | |
| typedef T | element_type | 
| Type of the data contained in the view.  | |
| typedef std::remove_cv< element_type >::type | value_type | 
| Type of variables of the type of the pointed-to data.  | |
| typedef std::add_const< value_type >::type | const_value_type | 
const version of the value_type .  | |
| typedef ptrdiff_t | difference_type | 
| Type for the distance between pointers or iterators.  | |
| typedef IdxType | size_type | 
Type for subscript / indexed access (eg.: operator[]).  | |
| typedef std::add_pointer< element_type >::type | pointer | 
| Type of a pointer to a contained value; potentially writable.  | |
| typedef std::add_pointer< element_type const >::type | const_pointer | 
| Type of a pointer to a contained value; view-only.  | |
| typedef pointer | iterator | 
| Iterator type; potentially writable.  | |
| typedef const_pointer | const_iterator | 
| Iterator type; view-only.  | |
| typedef std::reverse_iterator< iterator > | reverse_iterator | 
| Reverse iterator type; potentially writable.  | |
| typedef std::reverse_iterator< const_iterator > | const_reverse_iterator | 
| Reverse iterator type; view-only.  | |
Public Member Functions | |
| constexpr | array_ref () noexcept=default | 
| Trivial constructor; creates a view to nothing.  | |
| constexpr | array_ref (array_ref const &) noexcept=default | 
| Copy constructor (trivial)  | |
| constexpr array_ref & | operator= (array_ref const &) noexcept=default | 
| Assignment operator (trivial)  | |
| CXXO_CONSTEXPR | array_ref (pointer p, size_type len) CXXO_NOEXCEPTNOTHROW | 
| Construct a view to a buffer starting at p and of len units long.  | |
| CXXO_CONSTEXPR | array_ref (std::nullptr_t, pointer p, pointer q) CXXO_NOEXCEPTNOTHROW | 
| Construct a view to a buffer starting at p and ending at q (not in the original n3334 proposal).  | |
| template<size_t N> | |
| CXXO_CONSTEXPR | array_ref (T(&arr)[N]) CXXO_NOEXCEPTNOTHROW | 
| Constructs a view over a native C array.  | |
| reference | operator[] (size_type i) CXXO_NOEXCEPTNOTHROW | 
| Unchecked access to the i -th element.  | |
| CXXO_CONSTEXPR const_reference | operator[] (size_type i) const CXXO_NOEXCEPTNOTHROW | 
| Unchecked access to the i -th element.  | |
| reference | at (size_type i) | 
| Checked access to the i -th element; throw.  | |
| const_reference | at (size_type i) const | 
| Checked access to the i -th element; throw.  | |
| reference | at_or (size_type i, reference alt) CXXO_NOEXCEPTNOTHROW | 
| Checked access to the i -th element; returns an alternative if it doesn't exist.  | |
| CXXO_CONSTEXPR const_reference | at_or (size_type i, const_reference alt) const CXXO_NOEXCEPTNOTHROW | 
| Checked access to the i -th element; returns an alternative if it doesn't exist.  | |
| CXXO_CONSTEXPR size_type | size () const CXXO_NOEXCEPTNOTHROW | 
| CXXO_CONSTEXPR bool | empty () const CXXO_NOEXCEPTNOTHROW | 
| CXXO_CONSTEXPR14 pointer | data () CXXO_NOEXCEPTNOTHROW | 
| CXXO_CONSTEXPR const_pointer | data () const CXXO_NOEXCEPTNOTHROW | 
| CXXO_CONSTEXPR size_type | size_bytes () const CXXO_NOEXCEPTNOTHROW | 
| CXXO_CONSTEXPR const_iterator | cbegin () const CXXO_NOEXCEPTNOTHROW | 
| begin  | |
| CXXO_CONSTEXPR const_iterator | cend () const CXXO_NOEXCEPTNOTHROW | 
| end  | |
| iterator | begin () CXXO_NOEXCEPTNOTHROW | 
| begin  | |
| iterator | end () CXXO_NOEXCEPTNOTHROW | 
| end  | |
| CXXO_CONSTEXPR const_iterator | begin () const CXXO_NOEXCEPTNOTHROW | 
| begin  | |
| CXXO_CONSTEXPR const_iterator | end () const CXXO_NOEXCEPTNOTHROW | 
| end  | |
| CXXO_CONSTEXPR const_reverse_iterator | crbegin () const CXXO_NOEXCEPTNOTHROW | 
| reverse-begin  | |
| CXXO_CONSTEXPR const_reverse_iterator | crend () const CXXO_NOEXCEPTNOTHROW | 
| reverse-end  | |
| reverse_iterator | rbegin () CXXO_NOEXCEPTNOTHROW | 
| reverse-begin  | |
| reverse_iterator | rend () CXXO_NOEXCEPTNOTHROW | 
| reverse-end  | |
| const_reverse_iterator | rbegin () const CXXO_NOEXCEPTNOTHROW | 
| reverse-begin  | |
| const_reverse_iterator | rend () const CXXO_NOEXCEPTNOTHROW | 
| reverse-end  | |
| const_iterator | front () const CXXO_NOEXCEPTNOTHROW | 
| Unchecked (!) access to the 0th element.  | |
| iterator | front () CXXO_NOEXCEPTNOTHROW | 
| Unchecked (!) access to the 0th element.  | |
| const_iterator | back () const CXXO_NOEXCEPTNOTHROW | 
| Unchecked (!) access to the last element.  | |
| iterator | back () CXXO_NOEXCEPTNOTHROW | 
| Unchecked (!) access to the last element.  | |
| CXXO_CONSTEXPR array_ref | substr (size_type pos, size_type count) const | 
| Returns a view to the count -elements subsequence starting from pos .  | |
| array_ref | substr (size_type pos) const | 
| array_ref | leftmost (size_type n) const CXXO_NOEXCEPTNOTHROW | 
| Returns a view to the leftmost (first) n elements.  | |
| array_ref | rightmost (size_type n) const CXXO_NOEXCEPTNOTHROW | 
| Returns a view to the rightmost (last) n elements.  | |
| array_ref | slice (difference_type pos, size_type count) const | 
| Returns a view of sub-contents from position pos which can be negative, ala PHP, JS.  | |
| array_ref | slice (difference_type pos) const | 
| array_ref | without_back_n (size_type n) const | 
| Removes the last n elements.  | |
| array_ref | without_front_n (size_type n) const | 
| Removes the first n elements.  | |
| array_ref | without_back () const | 
| Returns a view with the last element removed.  | |
| array_ref | without_front () const | 
| Returns a view with the first element removed.  | |
An object representing a reference or slice of a contiguous area of memory of type T .
| T | Type of the kind of value contained in the view. | 
| IdxType | A numeric type to be used as the index, defaults to size_t . | 
A array_ref is a non-owning view of a sequence of contiguous elements via a simple {pointer+length} package. In many ways it could be considered an analogue to std::array except it doesn't actually hold the data (hence the name, array_ref ), and to std::reference_wrapper.
Being a reference/view type, it is good to pass by value. Also, iterator types are raw pointers.
This implementation is intended to be used for sequences of const elements (ie.: template argument is T const).
The utility function arrayref() and carrayref() help create array_refs from contexts where they can be needed.
See also: std::array, std::vector, seq_ .
array_ref of non-const objects.size_t (for eg.: short alloc buffers).pointer , pointer ) constructor.vector constructor for lower dependency overhead.front , back .leftmost , rightmost .arrayref() and carrayref() provided as support.array_ref is based in the original publication "n3334" by Jeffrey Yasskin
      
  | 
  inline | 
size_t . Referenced by array_ref< Ch const >::at_or(), array_ref< Ch const >::back(), basic_string_view< Ch, ChT >::copy(), array_ref< Ch const >::empty(), cxxomfort::string::find(), basic_string_view< Ch, ChT >::find(), basic_string_view< Ch, ChT >::length(), and basic_string_view< Ch, ChT >::substr().
      
  | 
  inline | 
bool . Referenced by array_ref< Ch const >::rightmost().
      
  | 
  inline | 
Referenced by array_ref< Ch const >::back(), basic_string_view< Ch, ChT >::copy(), cxxomfort::string::find(), and basic_string_view< Ch, ChT >::substr().
      
  | 
  inline | 
      
  | 
  inline | 
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
| array_ref slice | ( | difference_type | pos | ) | const | 
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 1.8.13