Classes | Namespaces | Macros | Typedefs | Functions | Variables
Gsl.hpp File Reference

Defines functions and classes from the GSL. More...

#include <algorithm>
#include <array>
#include <cstddef>
#include <iterator>
#include <limits>
#include <memory>
#include <stdexcept>
#include <type_traits>
#include <utility>
#include "ErrorHandling/ExpectsAndEnsures.hpp"
#include "Utilities/ForceInline.hpp"
#include "Utilities/Literals.hpp"
#include "Utilities/PrettyType.hpp"
#include "Utilities/Requires.hpp"

Go to the source code of this file.

Classes

class  gsl::not_null< T >
 Require a pointer to not be a nullptr More...
 
class  gsl::span< ElementType, Extent >
 Create a span/view on a range, which is cheap to copy (one pointer). More...
 
class  gsl::span< ElementType, Extent >
 Create a span/view on a range, which is cheap to copy (one pointer). More...
 

Namespaces

 gsl
 Implementations from the Guideline Support Library.
 

Macros

#define LIKELY(x)   (x)
 
#define UNLIKELY(x)   (x)
 

Typedefs

template<class T , Requires< std::is_pointer< T >::value > = nullptr>
using gsl::owner = typename detail::owner_impl< T >::type
 Mark a raw pointer as owning its data. More...
 

Functions

template<class T , class U >
constexpr T gsl::narrow_cast (U &&u) noexcept
 Cast u to a type T where the cast may result in narrowing.
 
template<class T , class U >
gsl::narrow (U u)
 A checked version of narrow_cast() that ERRORs if the cast changed the value.
 
template<class T >
std::ostreamgsl::operator<< (std::ostream &os, const not_null< T > &val)
 
template<class T , class U >
auto gsl::operator== (const not_null< T > &lhs, const not_null< U > &rhs) -> decltype(lhs.get()==rhs.get())
 
template<class T , class U >
auto gsl::operator!= (const not_null< T > &lhs, const not_null< U > &rhs) -> decltype(lhs.get() !=rhs.get())
 
template<class T , class U >
auto gsl::operator< (const not_null< T > &lhs, const not_null< U > &rhs) -> decltype(lhs.get()< rhs.get())
 
template<class T , class U >
auto gsl::operator<= (const not_null< T > &lhs, const not_null< U > &rhs) -> decltype(lhs.get()<=rhs.get())
 
template<class T , class U >
auto gsl::operator> (const not_null< T > &lhs, const not_null< U > &rhs) -> decltype(lhs.get() > rhs.get())
 
template<class T , class U >
auto gsl::operator>= (const not_null< T > &lhs, const not_null< U > &rhs) -> decltype(lhs.get() >=rhs.get())
 
template<class T , class U >
std::ptrdiff_t gsl::operator- (const not_null< T > &, const not_null< U > &)=delete
 
template<class T >
not_null< T > gsl::operator- (const not_null< T > &, std::ptrdiff_t)=delete
 
template<class T >
not_null< T > gsl::operator+ (const not_null< T > &, std::ptrdiff_t)=delete
 
template<class T >
not_null< T > gsl::operator+ (std::ptrdiff_t, const not_null< T > &)=delete
 
template<class ElementType , std::ptrdiff_t FirstExtent, std::ptrdiff_t SecondExtent>
constexpr bool gsl::operator== (span< ElementType, FirstExtent > l, span< ElementType, SecondExtent > r)
 
template<class ElementType , std::ptrdiff_t Extent>
constexpr bool gsl::operator!= (span< ElementType, Extent > l, span< ElementType, Extent > r)
 
template<class ElementType , std::ptrdiff_t Extent>
constexpr bool gsl::operator< (span< ElementType, Extent > l, span< ElementType, Extent > r)
 
template<class ElementType , std::ptrdiff_t Extent>
constexpr bool gsl::operator<= (span< ElementType, Extent > l, span< ElementType, Extent > r)
 
template<class ElementType , std::ptrdiff_t Extent>
constexpr bool gsl::operator> (span< ElementType, Extent > l, span< ElementType, Extent > r)
 
template<class ElementType , std::ptrdiff_t Extent>
constexpr bool gsl::operator>= (span< ElementType, Extent > l, span< ElementType, Extent > r)
 
template<class ElementType , std::ptrdiff_t Extent>
constexpr ElementType & gsl::at (span< ElementType, Extent > s, typename span< ElementType, Extent >::index_type i)
 
template<typename T >
gsl::not_null< T * > make_not_null (T *ptr) noexcept
 Construct a not_null from a pointer. Often this will be done as an implicit conversion, but it may be necessary to perform the conversion explicitly when type deduction is desired. More...
 
template<class T , std::size_t N, typename Size >
constexpr T & gsl::at (std::array< T, N > &arr, Size index)
 Retrieve a entry from a container, with checks in Debug mode that the index being retrieved is valid.
 
template<class Cont , typename Size >
constexpr const Cont::value_type & gsl::at (const Cont &cont, Size index)
 Retrieve a entry from a container, with checks in Debug mode that the index being retrieved is valid.
 
template<class T , typename Size >
constexpr const T & gsl::at (std::initializer_list< T > cont, Size index)
 Retrieve a entry from a container, with checks in Debug mode that the index being retrieved is valid.
 
template<class ElementType >
constexpr span< ElementType > gsl::make_span (ElementType *ptr, typename span< ElementType >::index_type count)
 Utility function for creating spans.
 
template<class ElementType >
constexpr span< ElementType > gsl::make_span (ElementType *firstElem, ElementType *lastElem)
 Utility function for creating spans.
 
template<class ElementType , std::size_t N>
constexpr span< ElementType, N > gsl::make_span (ElementType(&arr)[N]) noexcept
 Utility function for creating spans.
 
template<class Container >
constexpr span< typename Container::value_type > gsl::make_span (Container &cont)
 Utility function for creating spans.
 
template<class Container >
constexpr span< const typename Container::value_type > gsl::make_span (const Container &cont)
 Utility function for creating spans.
 
template<class Ptr >
constexpr span< typename Ptr::element_type > gsl::make_span (Ptr &cont, std::ptrdiff_t count)
 Utility function for creating spans.
 
template<class Ptr >
constexpr span< typename Ptr::element_type > gsl::make_span (Ptr &cont)
 Utility function for creating spans.
 

Variables

constexpr const std::ptrdiff_t gsl::dynamic_extent = -1
 

Detailed Description

Defines functions and classes from the GSL.

Function Documentation

◆ make_not_null()

template<typename T >
gsl::not_null<T*> make_not_null ( T *  ptr)
noexcept

Construct a not_null from a pointer. Often this will be done as an implicit conversion, but it may be necessary to perform the conversion explicitly when type deduction is desired.

Note
This is not a standard GSL function, and so is not in the gsl namespace.