PLYwoot
Header-only C++17 library for parsing and writing PLY files
Loading...
Searching...
No Matches
type_traits.hpp File Reference
#include "reflect.hpp"
#include "std.hpp"
#include "types.hpp"
#include <algorithm>
#include <type_traits>

Go to the source code of this file.

Functions

template<typename T >
constexpr bool plywoot::detail::isList ()
 
template<typename... Ts>
constexpr std::size_t plywoot::detail::numProperties ()
 
template<typename T >
constexpr bool plywoot::detail::isSame (PlyDataType type)
 
template<typename... Ts>
constexpr std::size_t plywoot::detail::sizeOf ()
 
constexpr std::size_t plywoot::detail::sizeOf (PlyDataType type)
 
template<typename Ptr >
constexpr Ptr plywoot::detail::align (Ptr ptr, PlyDataType type)
 
template<typename T >
constexpr bool plywoot::detail::isPacked (uintptr_t offset=0)
 
template<typename T , typename U , typename... Ts>
constexpr bool plywoot::detail::isPacked (uintptr_t offset=0)
 
template<typename... Ts>
constexpr bool plywoot::detail::isTriviallyCopyable ()
 
template<typename T >
bool plywoot::detail::isMemcpyable (const PlyPropertyConstIterator first, const PlyPropertyConstIterator last)
 
template<typename T , typename U , typename... Ts>
bool plywoot::detail::isMemcpyable (const PlyPropertyConstIterator first, const PlyPropertyConstIterator last)
 

Function Documentation

◆ align()

template<typename Ptr >
constexpr Ptr plywoot::detail::align ( Ptr  ptr,
PlyDataType  type 
)
constexpr

Aligns the given input pointer according to the size of the given PLY data type.

Parameters
ptrinput point to align
typePLY data type of the object pointed to by ptr
Returns
the input pointer ptr aligned according to the alignment requirements for the given PLY data type type

Definition at line 249 of file type_traits.hpp.

◆ isList()

template<typename T >
constexpr bool plywoot::detail::isList ( )
constexpr

Returns whether the given reflection type T represents a list.

Template Parameters
Ttype for which to calculate whether it represents a list
Returns
true in case the given type T represents a list

Definition at line 66 of file type_traits.hpp.

◆ isMemcpyable() [1/2]

template<typename T >
bool plywoot::detail::isMemcpyable ( const PlyPropertyConstIterator  first,
const PlyPropertyConstIterator  last 
)

Returns whether the range of properties in [first, last) represents PLY properties that have the same type as the given type range. Note that a single reflect::Pack type is compared with same number of properties as are in the pack.

Parameters
firstiterator pointing to the first property in the range of input PLY properties
lastiterator pointing after the last property in the range of input PLY properties
Returns
true in case all PLY properties in the given range are memcpy'able, false otherwise

Definition at line 355 of file type_traits.hpp.

◆ isMemcpyable() [2/2]

template<typename T , typename U , typename... Ts>
bool plywoot::detail::isMemcpyable ( const PlyPropertyConstIterator  first,
const PlyPropertyConstIterator  last 
)

Returns whether the range of properties in [first, last) represents PLY properties that have the same type as the given type range. Note that a single reflect::Pack type is compared with same number of properties as are in the pack.

Parameters
firstiterator pointing to the first property in the range of input PLY properties
lastiterator pointing after the last property in the range of input PLY properties
Returns
true in case all PLY properties in the given range are memcpy'able, false otherwise

Definition at line 372 of file type_traits.hpp.

◆ isPacked() [1/2]

template<typename T >
constexpr bool plywoot::detail::isPacked ( uintptr_t  offset = 0)
constexpr

Type function that returns whether a type is aligned in memory at the given memory offset.

Template Parameters
Ttype to check whether it is aligned in memory at the given offset
Parameters
offsetrelative memory offset at which an object of type T is to be stored
Returns
true in case the given type is packed, false otherwise

Definition at line 283 of file type_traits.hpp.

◆ isPacked() [2/2]

template<typename T , typename U , typename... Ts>
constexpr bool plywoot::detail::isPacked ( uintptr_t  offset = 0)
constexpr

Type function that returns whether a list of types are consecutively aligned in memory, without any padding, at the given memory offset.

Parameters
offsetrelative memory offset at which an object of type T is to be stored
Returns
true in case the given type is packed, false otherwise

Definition at line 295 of file type_traits.hpp.

◆ isSame()

template<typename T >
constexpr bool plywoot::detail::isSame ( PlyDataType  type)
constexpr

Returns whether an object of type T represents that same object as an object of the given PLY data type type.

Template Parameters
Ttype to check for equality with the PLY data type type
Parameters
typePLY data type to check for equality with T
Returns
true in case an type T equals the given PLY data type type

Definition at line 130 of file type_traits.hpp.

◆ isTriviallyCopyable()

template<typename... Ts>
constexpr bool plywoot::detail::isTriviallyCopyable ( )
constexpr

Type function that returns whether all types in the given list of types are trivially copyable, that is, they do not have a custom copy constructor non-standard implementation.

Template Parameters
T,U,Ts...type for which to check whether it is trivially copyable
Returns
true in case all types passed in as template parameters are trivially copyable, false otherwise

Definition at line 308 of file type_traits.hpp.

◆ numProperties()

template<typename... Ts>
constexpr std::size_t plywoot::detail::numProperties ( )
constexpr

Returns the number of properties spanned by the given list of reflection types. By default, every reflection type spans one property, except for plywoot::reflect::Pack, which spans multiple properties by definition.

Returns
the number of properties spanned by the given list of reflection types

Definition at line 118 of file type_traits.hpp.

◆ sizeOf() [1/2]

template<typename... Ts>
constexpr std::size_t plywoot::detail::sizeOf ( )
constexpr

Returns the size of some type T, effectively implementing sizeof(T), where it overrides sizeof() for types of instance Pack<> and Array<>. For pack types, the computed size is the sum of SizeOf for all types in the pack, whereas for arrays it is the SizeOf of the element type in the array times the number of elements in the array.

Returns
the sum of the size in bytes of the given list of reflection types Ts...

Definition at line 211 of file type_traits.hpp.

◆ sizeOf() [2/2]

constexpr std::size_t plywoot::detail::sizeOf ( PlyDataType  type)
constexpr

Returns the size in bytes of the given PLY data type.

Parameters
typePLY data type to calculate the size for
Returns
the size in bytes of the given PLY data type

Definition at line 220 of file type_traits.hpp.