tinypbrt 1.1.1
pbrt-v4 scene file parser for C11 with a header-only C++20 wrapper
Loading...
Searching...
No Matches
tpbrt::array< Native, Element, DataField > Struct Template Reference

Generic C++ array view with type conversion (a non owning view on memory owned by the C library). More...

#include <tinypbrt/detail/cpp/common.hpp>

Public Types

using traits = detail::array_traits< Native, DataField >
 Array traits.
 
using native_element_type = traits::native_element_type
 Native C library array element type.
 
using element_type = std::conditional_t< std::is_void_v< Element >, native_element_type, Element >
 C++ array view element type.
 
using value_type = element_type
 Value type (as in std::span).
 
using span_type = traits::span_type
 std::span type of this array.
 
using iterator = std::conditional_t< IsIdentity, typename span_type::iterator, detail::converting_iterator< native_element_type, element_type > >
 Iterator type.
 
using reference = std::conditional_t< IsIdentity, const native_element_type &, element_type >
 Type returned by operator[] (a reference for identity arrays, a converted value otherwise).
 

Public Member Functions

constexpr size_t size () const noexcept
 Returns size of this array.
 
constexpr bool_t empty () const noexcept
 Returns true if array is empty.
 
constexpr const native_element_type * data () const noexcept
 Returns pointer to the C data.
 
constexpr span_type to_span () const noexcept
 Returns std::span over the C data.
 
constexpr iterator begin () const noexcept
 Returns begin iterator.
 
constexpr iterator end () const noexcept
 Returns end iterator.
 
constexpr reference operator[] (const size_t index) const noexcept
 Returns element on given index (unchecked, like std::span).
 
constexpr result< element_type > at (const size_t index) const noexcept
 Returns element on given index or error::INDEX_OUT_OF_RANGE.
 
constexpr reference front () const noexcept
 Returns first element (unchecked).
 
constexpr reference back () const noexcept
 Returns last element (unchecked).
 
constexpr auto operator<=> (const array &rhs) const noexcept
 Three-way comparison operator (compares elements).
 
constexpr bool_t operator== (const array &rhs) const noexcept
 Equality operator (compares elements).
 

Static Public Attributes

static constexpr size_t Extent = traits::Extent
 Array static size.
 
static constexpr bool_t IsIdentity = std::is_same_v<native_element_type, element_type>
 True when elements are returned without conversion (as references to the C data).
 

Protected Member Functions

constexpr span_type _raw_span () const noexcept
 Returns std::span over the C data.
 

Detailed Description

template<class Native, class Element, auto DataField>
struct tpbrt::array< Native, Element, DataField >

Generic C++ array view with type conversion (a non owning view on memory owned by the C library).

Generic C++ array view with type conversion.

Behaves like std::span: operator[] is unchecked, at() returns tpbrt::result with INDEX_OUT_OF_RANGE. Iterators stay valid after the array object itself is destroyed (borrowed range), as long as the scene lives.

Template Parameters
NativeType of C library native array type.
ElementDesired array element type (if different from the native element type, every element is converted).
DataFieldPointer to field with data.
NativeType of C library native array type.
ElementDesired array element type (if not the same as the native element type, transformation is performed).
DataFieldPointer to field with data.

Member Typedef Documentation

◆ traits

template<class Native , class Element , auto DataField>
using tpbrt::array< Native, Element, DataField >::traits = detail::array_traits<Native, DataField>

Array traits.

◆ native_element_type

template<class Native , class Element , auto DataField>
using tpbrt::array< Native, Element, DataField >::native_element_type = traits::native_element_type

Native C library array element type.

◆ element_type

template<class Native , class Element , auto DataField>
using tpbrt::array< Native, Element, DataField >::element_type = std::conditional_t<std::is_void_v<Element>, native_element_type, Element>

C++ array view element type.

◆ value_type

template<class Native , class Element , auto DataField>
using tpbrt::array< Native, Element, DataField >::value_type = element_type

Value type (as in std::span).

◆ span_type

template<class Native , class Element , auto DataField>
using tpbrt::array< Native, Element, DataField >::span_type = traits::span_type

std::span type of this array.

◆ iterator

template<class Native , class Element , auto DataField>
using tpbrt::array< Native, Element, DataField >::iterator = std::conditional_t<IsIdentity, typename span_type::iterator, detail::converting_iterator<native_element_type, element_type> >

Iterator type.

◆ reference

template<class Native , class Element , auto DataField>
using tpbrt::array< Native, Element, DataField >::reference = std::conditional_t<IsIdentity, const native_element_type&, element_type>

Type returned by operator[] (a reference for identity arrays, a converted value otherwise).

Member Function Documentation

◆ _raw_span()

template<class Native , class Element , auto DataField>
constexpr span_type tpbrt::array< Native, Element, DataField >::_raw_span ( ) const
inlineconstexprprotectednoexcept

Returns std::span over the C data.

◆ size()

template<class Native , class Element , auto DataField>
constexpr size_t tpbrt::array< Native, Element, DataField >::size ( ) const
inlineconstexprnoexcept

Returns size of this array.

Examples
examples/cpp/quickstart/main.cpp.

◆ empty()

template<class Native , class Element , auto DataField>
constexpr bool_t tpbrt::array< Native, Element, DataField >::empty ( ) const
inlineconstexprnoexcept

Returns true if array is empty.

◆ data()

template<class Native , class Element , auto DataField>
constexpr const native_element_type * tpbrt::array< Native, Element, DataField >::data ( ) const
inlineconstexprnoexcept

Returns pointer to the C data.

◆ to_span()

template<class Native , class Element , auto DataField>
constexpr span_type tpbrt::array< Native, Element, DataField >::to_span ( ) const
inlineconstexprnoexcept

Returns std::span over the C data.

◆ begin()

template<class Native , class Element , auto DataField>
constexpr iterator tpbrt::array< Native, Element, DataField >::begin ( ) const
inlineconstexprnoexcept

Returns begin iterator.

◆ end()

template<class Native , class Element , auto DataField>
constexpr iterator tpbrt::array< Native, Element, DataField >::end ( ) const
inlineconstexprnoexcept

Returns end iterator.

◆ operator[]()

template<class Native , class Element , auto DataField>
constexpr reference tpbrt::array< Native, Element, DataField >::operator[] ( const size_t  index) const
inlineconstexprnoexcept

Returns element on given index (unchecked, like std::span).

◆ at()

template<class Native , class Element , auto DataField>
constexpr result< element_type > tpbrt::array< Native, Element, DataField >::at ( const size_t  index) const
inlineconstexprnoexcept

Returns element on given index or error::INDEX_OUT_OF_RANGE.

◆ front()

template<class Native , class Element , auto DataField>
constexpr reference tpbrt::array< Native, Element, DataField >::front ( ) const
inlineconstexprnoexcept

Returns first element (unchecked).

◆ back()

template<class Native , class Element , auto DataField>
constexpr reference tpbrt::array< Native, Element, DataField >::back ( ) const
inlineconstexprnoexcept

Returns last element (unchecked).

◆ operator<=>()

template<class Native , class Element , auto DataField>
constexpr auto tpbrt::array< Native, Element, DataField >::operator<=> ( const array< Native, Element, DataField > &  rhs) const
inlineconstexprnoexcept

Three-way comparison operator (compares elements).

◆ operator==()

template<class Native , class Element , auto DataField>
constexpr bool_t tpbrt::array< Native, Element, DataField >::operator== ( const array< Native, Element, DataField > &  rhs) const
inlineconstexprnoexcept

Equality operator (compares elements).

Field Documentation

◆ Extent

template<class Native , class Element , auto DataField>
constexpr size_t tpbrt::array< Native, Element, DataField >::Extent = traits::Extent
staticconstexpr

Array static size.

◆ IsIdentity

template<class Native , class Element , auto DataField>
constexpr bool_t tpbrt::array< Native, Element, DataField >::IsIdentity = std::is_same_v<native_element_type, element_type>
staticconstexpr

True when elements are returned without conversion (as references to the C data).


The documentation for this struct was generated from the following file: