cpp-sdl2
C++ header-only SDL2 wrapper
sdl::simd Namespace Reference

Namespaces

 details
 

Classes

struct  allocator
 Allocator usable with standard containers. More...
 
struct  deleter
 deleter usable with std::unique_ptr<T>. More...
 
class  deleter< T[]>
 deleter usable with std::unique_ptr<T[]>. More...
 

Typedefs

template<typename T >
using unique_ptr = std::unique_ptr< T, simd::deleter< T > >
 

Functions

size_t get_alignment ()
 Report the alignment this system needs for SIMD allocations. More...
 
void * alloc (size_t len)
 Allocate memory in a SIMD-friendly way. More...
 
void free (void *ptr)
 Deallocate memory obtained from sdl::simd::alloc(). More...
 
template<typename T , typename... Args>
auto make_unique (Args &&... args) -> std::enable_if_t<!std::is_array_v< T >, unique_ptr< T >>
 Equivalent of std::make_unique<T> that returns a simd::unique_ptr. More...
 
template<typename T >
auto make_unique (std::size_t count) -> std::enable_if_t< std::is_array_v< T > &&std::extent_v< T >==0
 Allocate and default construct count elements. More...
 
 for (std::size_t i=0;i< count;++i) new(mem+i) U
 
return unique_ptr< T > (mem, deleter< T >(count))
 
template<typename T , typename... Args>
auto make_shared (Args &&... args) -> std::enable_if<!std::is_array_v< T >, std::shared_ptr< T >>
 Equivalent of std::make_shared<T> that uses simd-friendly storage. More...
 

Variables

auto unique_ptr< T > = delete
 
allocator< U > a
 
auto * mem = a.allocate(count)
 

Typedef Documentation

◆ unique_ptr

template<typename T >
using sdl::simd::unique_ptr = typedef std::unique_ptr<T, simd::deleter<T> >

Definition at line 124 of file simd.hpp.

Function Documentation

◆ alloc()

void* sdl::simd::alloc ( size_t  len)
inline

Allocate memory in a SIMD-friendly way.

See SDL_SIMDAlloc for more info.

Definition at line 21 of file simd.hpp.

Referenced by sdl::simd::allocator< T >::allocate().

◆ for()

sdl::simd::for ( )
new

◆ free()

void sdl::simd::free ( void *  ptr)
inline

◆ get_alignment()

size_t sdl::simd::get_alignment ( )
inline

Report the alignment this system needs for SIMD allocations.

See SDL_SIMDGetAlignment for more info.

Definition at line 14 of file simd.hpp.

◆ make_shared()

template<typename T , typename... Args>
auto sdl::simd::make_shared ( Args &&...  args) -> std::enable_if<!std::is_array_v<T>, std::shared_ptr<T>>

Equivalent of std::make_shared<T> that uses simd-friendly storage.

Definition at line 152 of file simd.hpp.

References a, sdl::simd::allocator< T >::allocate(), and mem.

◆ make_unique() [1/2]

template<typename T , typename... Args>
auto sdl::simd::make_unique ( Args &&...  args) -> std::enable_if_t<!std::is_array_v<T>, unique_ptr<T>>

Equivalent of std::make_unique<T> that returns a simd::unique_ptr.

make_unique<T[N]> is deleted.

Definition at line 128 of file simd.hpp.

References a, and sdl::simd::allocator< T >::allocate().

◆ make_unique() [2/2]

template<typename T >
auto sdl::simd::make_unique ( std::size_t  count) -> std::enable_if_t<std::is_array_v<T> && std::extent_v<T> =
pure virtual

Allocate and default construct count elements.

◆ unique_ptr< T >()

return sdl::simd::unique_ptr< T > ( mem  ,
deleter< T >  count 
)

Variable Documentation

◆ a

◆ mem

auto* sdl::simd::mem = a.allocate(count)

Definition at line 145 of file simd.hpp.

Referenced by sdl::simd::allocator< T >::allocate(), and make_shared().

◆ unique_ptr< T >

auto sdl::simd::unique_ptr< T > = delete

Definition at line 136 of file simd.hpp.