dune-common 2.12-git
Loading...
Searching...
No Matches
Dune::Std Namespace Reference

Namespace for features backported from new C++ standards. More...

Classes

struct  compare_three_way
 A functor implementing the three-way comparison on the arguments. More...
 
class  default_accessor
 A type for indexed access to elements of mdspan. More...
 
struct  extent_slice
 Slice specifier selecting extent entries starting at offset with a stride. More...
 
class  extents
 Multidimensional index space with dynamic and static extents. More...
 
struct  full_extent_t
 Slice specifier selecting the full extent in one mdspan dimension. More...
 
struct  identity
 A function object type whose operator() returns its argument unchanged. More...
 
struct  layout_left
 A layout where the leftmost extent has stride 1. More...
 
struct  layout_left_padded
 A layout mapping where the leftmost extent has stride 1 and the second stride may be padded. More...
 
struct  layout_right
 A layout where the rightmost extent has stride 1, and strides increase right-to-left as the product of extents. More...
 
struct  layout_right_padded
 A layout mapping where the rightmost extent has stride 1 and the next-to-last stride may be padded. More...
 
struct  layout_stride
 A layout mapping where the strides are user-defined. More...
 
class  mdarray
 An owning multi-dimensional array analog of mdspan. More...
 
class  mdspan
 A multi-dimensional non-owning array view. More...
 
struct  nonesuch
 Type representing a lookup failure by std::detected_or and friends. More...
 
struct  range_slice
 Slice specifier selecting the half-open range [first,last) with a stride. More...
 
class  span
 A contiguous sequence of elements with static or dynamic extent. More...
 
struct  submdspan_mapping_result
 Result type returned by submdspan_mapping. More...
 

Concepts

concept  three_way_comparable
 The concept std::three_way_comparable specifies that the three way comparison operator <=> on T yield results consistent with the comparison category implied by Cat.
 
concept  three_way_comparable_with
 The concept std::three_way_comparable_with specifies that the three way comparison operator <=> on (possibly mixed) T and U operands yield results consistent with the comparison category implied by Cat. Comparing mixed operands yields results equivalent to comparing the operands converted to their common type.
 
concept  indirectly_copyable
 The std::indirectly_copyable concept specifies the relationship between an indirectly_readable type and a type that is indirectly_writable. The indirectly_writable type must be able to directly copy the object that the indirectly_readable type references.
 

Typedefs

template<class IndexType , std::size_t R>
using dextents = typename Impl::DExtentsImpl< IndexType, std::make_integer_sequence< std::size_t, R > >::type
 Alias of extents of given rank R and purely dynamic extents. See [mdspan.extents.dextents].
 
template<std::size_t R, class IndexType = std::size_t>
using dims = dextents< IndexType, R >
 Alias of dextents of given rank R, defaulting the index type to std::size_t. See [mdspan.extents.dims].
 
template<class OffsetType , class ExtentType , class StrideType >
using strided_slice = extent_slice< OffsetType, ExtentType, StrideType >
 Compatibility spelling for a strided extent slice.
 
template<typename Default , template< typename... > class Op, typename... Args>
using detected_or = Impl::detector< Default, void, Op, Args... >
 Detects whether Op<Args...> is valid and makes the result available.
 
template<template< typename... > class Op, typename... Args>
using is_detected = typename detected_or< nonesuch, Op, Args... >::value_t
 Detects whether Op<Args...> is valid.
 
template<template< typename... > class Op, typename... Args>
using detected_t = typename detected_or< nonesuch, Op, Args... >::type
 Returns Op<Args...> if that is valid; otherwise returns nonesuch.
 
template<typename Default , template< typename... > class Op, typename... Args>
using detected_or_t = typename detected_or< Default, Op, Args... >::type
 Returns Op<Args...> if that is valid; otherwise returns the fallback type Default.
 
template<typename Expected , template< typename... > class Op, typename... Args>
using is_detected_exact = std::is_same< Expected, detected_t< Op, Args... > >
 Checks whether Op<Args...> is Expected without causing an error if Op<Args...> is invalid.
 
template<typename Target , template< typename... > class Op, typename... Args>
using is_detected_convertible = std::is_convertible< Target, detected_t< Op, Args... > >
 Checks whether Op<Args...> is convertible to Target without causing an error if Op<Args...> is invalid.
 

Functions

template<class I1 , class I2 , class Cmp = Std::compare_three_way>
constexpr auto lexicographical_compare_three_way (I1 f1, I1 l1, I2 f2, I2 l2, Cmp comp={}) -> decltype(comp(*f1, *f2))
 Lexicographically compares two ranges [first1, last1) and [first2, last2) using three-way comparison and produces a result of the strongest applicable comparison category type.
 
template<class T >
constexpr T abs (T t)
 
template<class T >
requires (std::is_floating_point_v<T> || std::is_integral_v<T>)
constexpr auto sqrt (T t)
 
template<class CArray , std::enable_if_t< std::is_array_v< CArray >, int > = 0, std::enable_if_t<(std::rank_v< CArray >==1), int > = 0>
 mdspan (CArray &) -> mdspan< std::remove_all_extents_t< CArray >, Std::extents< std::size_t, std::extent_v< CArray, 0 > > >
 
template<class Pointer , std::enable_if_t< std::is_pointer_v< std::remove_reference_t< Pointer > >, int > = 0>
 mdspan (Pointer &&) -> mdspan< std::remove_pointer_t< std::remove_reference_t< Pointer > >, Std::extents< std::size_t > >
 
template<class ElementType , class... II, std::enable_if_t<(... &&std::is_convertible_v< II, std::size_t >), int > = 0, std::enable_if_t<(sizeof...(II) > 0), int > = 0>
 mdspan (ElementType *, II...) -> mdspan< ElementType, Std::dextents< std::size_t, sizeof...(II)> >
 
template<class ElementType , class SizeType , std::size_t N>
 mdspan (ElementType *, std::span< SizeType, N >) -> mdspan< ElementType, Std::dextents< std::size_t, N > >
 
template<class ElementType , class SizeType , std::size_t N>
 mdspan (ElementType *, const std::array< SizeType, N > &) -> mdspan< ElementType, Std::dextents< std::size_t, N > >
 
template<class ElementType , class IndexType , std::size_t... exts>
 mdspan (ElementType *, const Std::extents< IndexType, exts... > &) -> mdspan< ElementType, Std::extents< IndexType, exts... > >
 
template<class ElementType , class Mapping , class Extents = typename Mapping::extents_type, class Layout = typename Mapping::layout_type>
 mdspan (ElementType *, const Mapping &) -> mdspan< ElementType, Extents, Layout >
 
template<class Mapping , class Accessor , class DataHandle = typename Accessor::data_handle_type, class Element = typename Accessor::element_type, class Extents = typename Mapping::extents_type, class Layout = typename Mapping::layout_type>
 mdspan (const DataHandle &, const Mapping &, const Accessor &) -> mdspan< Element, Extents, Layout, Accessor >
 
template<class T >
constexpr auto to_address (T &&p) noexcept
 Obtain the address represented by p without forming a reference to the object pointed to by p.
 
template<class T , std::size_t N>
 span (T(&)[N]) -> span< T, N >
 
template<class ElementType , class I , std::size_t Extent, std::enable_if_t< std::is_convertible_v< I, std::size_t >, int > = 0>
 span (ElementType *, std::integral_constant< I, Extent >) -> span< ElementType, Extent >
 
template<class ElementType , class I , std::enable_if_t< std::is_integral_v< I >, int > = 0, std::enable_if_t< std::is_convertible_v< I, std::size_t >, int > = 0>
 span (ElementType *, I) -> span< ElementType, Std::dynamic_extent >
 
template<class Iter , class Element = std::remove_reference_t<decltype(*std::declval<Iter>())>>
 span (Iter, Iter) -> span< Element, Std::dynamic_extent >
 
template<class Range , class First = decltype(std::begin(std::declval<Range>())), class Last = decltype(std::end(std::declval<Range>())), class Element = std::remove_reference_t<decltype(*std::declval<First>())>>
 span (Range &) -> span< Element, Std::dynamic_extent >
 
template<class T , size_t N>
 span (std::array< T, N > &) -> span< T, N >
 
template<class T , size_t N>
 span (const std::array< T, N > &) -> span< const T, N >
 
template<class IndexType , std::size_t... exts, class... SliceSpecifiers, std::enable_if_t<(sizeof...(SliceSpecifiers)==sizeof...(exts)), int > = 0>
constexpr auto subextents (const extents< IndexType, exts... > &src, SliceSpecifiers... slices)
 Return the extents produced by slicing a source extents object.
 
template<class Mapping , class... SliceSpecifiers, std::enable_if_t<(sizeof...(SliceSpecifiers)==Mapping::extents_type::rank()), int > = 0>
constexpr auto submdspan_mapping (const Mapping &mapping, SliceSpecifiers... slices)
 Create the mapping and source-data offset produced by slicing a layout mapping.
 
template<class ElementType , class Extents , class LayoutPolicy , class AccessorPolicy , class... SliceSpecifiers, std::enable_if_t<(sizeof...(SliceSpecifiers)==Extents::rank()), int > = 0>
constexpr auto submdspan (const mdspan< ElementType, Extents, LayoutPolicy, AccessorPolicy > &src, SliceSpecifiers... slices)
 Create an mdspan view by slicing an existing mdspan.
 
template<class OffsetType , class ExtentType , class StrideType >
 extent_slice (OffsetType, ExtentType, StrideType) -> extent_slice< OffsetType, ExtentType, StrideType >
 
template<class FirstType , class LastType >
 range_slice (FirstType, LastType) -> range_slice< FirstType, LastType >
 
template<class FirstType , class LastType , class StrideType >
 range_slice (FirstType, LastType, StrideType) -> range_slice< FirstType, LastType, StrideType >
 

Variables

constexpr std::size_t dynamic_extent = std::dynamic_extent
 A constant of type std::size_t that is used to differentiate std::span of static and dynamic extent.
 
constexpr full_extent_t full_extent {}
 Slice specifier selecting the full extent in one mdspan dimension.
 

Detailed Description

Namespace for features backported from new C++ standards.

The namespace Dune::Std contains library features of new C++ standards and technical specifications backported to older compilers. Most features are detected and pulled into this namespace from the standard library if your compiler has native support. If it doesn't, we provide a fallback implementation on a best-effort basis.

Function Documentation

◆ abs()

template<class T >
constexpr T Dune::Std::abs ( T  t)
constexpr

◆ extent_slice()

template<class OffsetType , class ExtentType , class StrideType >
Dune::Std::extent_slice ( OffsetType  ,
ExtentType  ,
StrideType   
) -> extent_slice< OffsetType, ExtentType, StrideType >

◆ lexicographical_compare_three_way()

template<class I1 , class I2 , class Cmp = Std::compare_three_way>
constexpr auto Dune::Std::lexicographical_compare_three_way ( I1  f1,
I1  l1,
I2  f2,
I2  l2,
Cmp  comp = {} 
) -> decltype(comp(*f1, *f2))
constexpr

Lexicographically compares two ranges [first1, last1) and [first2, last2) using three-way comparison and produces a result of the strongest applicable comparison category type.

Implementation taken from https://en.cppreference.com/w/cpp/algorithm/lexicographical_compare_three_way

The standard implementation is available with libstdc++ >= 10 and libc++ >= 17

◆ mdspan() [1/8]

template<class CArray , std::enable_if_t< std::is_array_v< CArray >, int > = 0, std::enable_if_t<(std::rank_v< CArray >==1), int > = 0>
Dune::Std::mdspan ( CArray &  ) -> mdspan< std::remove_all_extents_t< CArray >, Std::extents< std::size_t, std::extent_v< CArray, 0 > > >

◆ mdspan() [2/8]

template<class Mapping , class Accessor , class DataHandle = typename Accessor::data_handle_type, class Element = typename Accessor::element_type, class Extents = typename Mapping::extents_type, class Layout = typename Mapping::layout_type>
Dune::Std::mdspan ( const DataHandle &  ,
const Mapping &  ,
const Accessor &   
) -> mdspan< Element, Extents, Layout, Accessor >

◆ mdspan() [3/8]

template<class ElementType , class Mapping , class Extents = typename Mapping::extents_type, class Layout = typename Mapping::layout_type>
Dune::Std::mdspan ( ElementType *  ,
const Mapping &   
) -> mdspan< ElementType, Extents, Layout >

◆ mdspan() [4/8]

template<class ElementType , class SizeType , std::size_t N>
Dune::Std::mdspan ( ElementType *  ,
const std::array< SizeType, N > &   
) -> mdspan< ElementType, Std::dextents< std::size_t, N > >

◆ mdspan() [5/8]

template<class ElementType , class IndexType , std::size_t... exts>
Dune::Std::mdspan ( ElementType *  ,
const Std::extents< IndexType, exts... > &   
) -> mdspan< ElementType, Std::extents< IndexType, exts... > >

◆ mdspan() [6/8]

template<class ElementType , class... II, std::enable_if_t<(... &&std::is_convertible_v< II, std::size_t >), int > = 0, std::enable_if_t<(sizeof...(II) > 0), int > = 0>
Dune::Std::mdspan ( ElementType *  ,
II...   
) -> mdspan< ElementType, Std::dextents< std::size_t, sizeof...(II)> >

◆ mdspan() [7/8]

template<class ElementType , class SizeType , std::size_t N>
Dune::Std::mdspan ( ElementType *  ,
std::span< SizeType, N >   
) -> mdspan< ElementType, Std::dextents< std::size_t, N > >

◆ mdspan() [8/8]

template<class Pointer , std::enable_if_t< std::is_pointer_v< std::remove_reference_t< Pointer > >, int > = 0>
Dune::Std::mdspan ( Pointer &&  ) -> mdspan< std::remove_pointer_t< std::remove_reference_t< Pointer > >, Std::extents< std::size_t > >

◆ range_slice() [1/2]

template<class FirstType , class LastType >
Dune::Std::range_slice ( FirstType  ,
LastType   
) -> range_slice< FirstType, LastType >

◆ range_slice() [2/2]

template<class FirstType , class LastType , class StrideType >
Dune::Std::range_slice ( FirstType  ,
LastType  ,
StrideType   
) -> range_slice< FirstType, LastType, StrideType >

◆ span() [1/7]

template<class T , size_t N>
Dune::Std::span ( const std::array< T, N > &  ) -> span< const T, N >

◆ span() [2/7]

template<class ElementType , class I , std::enable_if_t< std::is_integral_v< I >, int > = 0, std::enable_if_t< std::is_convertible_v< I, std::size_t >, int > = 0>
Dune::Std::span ( ElementType *  ,
I   
) -> span< ElementType, Std::dynamic_extent >

◆ span() [3/7]

template<class ElementType , class I , std::size_t Extent, std::enable_if_t< std::is_convertible_v< I, std::size_t >, int > = 0>
Dune::Std::span ( ElementType *  ,
std::integral_constant< I, Extent >   
) -> span< ElementType, Extent >

◆ span() [4/7]

template<class Iter , class Element = std::remove_reference_t<decltype(*std::declval<Iter>())>>
Dune::Std::span ( Iter  ,
Iter   
) -> span< Element, Std::dynamic_extent >

◆ span() [5/7]

template<class Range , class First = decltype(std::begin(std::declval<Range>())), class Last = decltype(std::end(std::declval<Range>())), class Element = std::remove_reference_t<decltype(*std::declval<First>())>>
Dune::Std::span ( Range &  ) -> span< Element, Std::dynamic_extent >

◆ span() [6/7]

template<class T , size_t N>
Dune::Std::span ( std::array< T, N > &  ) -> span< T, N >

◆ span() [7/7]

template<class T , std::size_t N>
Dune::Std::span ( T(&)  [N]) -> span< T, N >

◆ sqrt()

template<class T >
requires (std::is_floating_point_v<T> || std::is_integral_v<T>)
constexpr auto Dune::Std::sqrt ( T  t)
constexpr

◆ to_address()

template<class T >
constexpr auto Dune::Std::to_address ( T &&  p)
constexprnoexcept

Obtain the address represented by p without forming a reference to the object pointed to by p.

Variable Documentation

◆ dynamic_extent

constexpr std::size_t Dune::Std::dynamic_extent = std::dynamic_extent
inlineconstexpr

A constant of type std::size_t that is used to differentiate std::span of static and dynamic extent.