Support Class Library
A set of tools providing classes and utility
Functions
scl::tools::make Namespace Reference

Group of factory functions. More...

Functions

template<class T , class... Args>
scl::utils::Any any (Args &&... args)
 Creates an scl::tools::Any from the given type and arguments. More...
 
template<class T , class... Args>
std::atomic< T > atomic (Args &&... args)
 Creates an atomic in-place with the given set of arguments. More...
 
template<class T , class... Args>
from (Args &&... args)
 Instantiate the given value type in-place with the given set of arguments. More...
 
template<class T , class... Args>
scl::async::Mutexed< T > mutexed (Args &&... args)
 Creates a scl::async::Mutexed from the given type and arguments. More...
 
template<class T , class... Args>
constexpr scl::utils::Optional< T > optional (Args &&... args)
 Creates an scl::utils::Optional with a constructed value. More...
 
template<class T >
constexpr scl::utils::Optional< T > emptyOptional ()
 Creates an empty optional. More...
 
template<class T , class... Args>
constexpr scl::utils::Optional< T > some (Args &&... args)
 Alias for scl::tools::make::optional. More...
 
template<class T >
constexpr scl::utils::Optional< T > none ()
 Alias for scl::tools::make::emptyOptional. More...
 
template<class T >
constexpr scl::utils::Optional< T > optionalFromPointer (const T *ptr)
 Creates an optional from a pointer. More...
 
template<class T , class... Args>
std::promise< T > promise (Args &&... args)
 Creates a fulfilled std::promise in-place with the given set of arguments. More...
 
template<class T , class... Args>
T * ptr (Args &&... args)
 Creates a pointer in-place with the given set of arguments (using new) More...
 
template<class T , class E = scl::utils::Placeholder>
scl::utils::Result< T, E > ok (const T &value)
 
template<class T , class E >
scl::utils::Result< T, E > err (const E &error)
 
template<class T , class... Args>
std::shared_ptr< T > shared (Args &&... args)
 Creates a shared_ptr in-place with the given set of arguments. More...
 
template<class T , class... Args>
std::unique_ptr< T > unique (Args &&... args)
 Creates a unique_ptr in-place with the given set of arguments. More...
 

Detailed Description

Group of factory functions.

Function Documentation

◆ any()

template<class T , class... Args>
scl::utils::Any scl::tools::make::any ( Args &&...  args)

Creates an scl::tools::Any from the given type and arguments.

Template Parameters
Tbeing the stored value type
Argsbeing the arguments' types
Parameters
argsbeing the arguments to pass to the value type's constructor
Returns
an initialized Any whose value type is forced to be T

Definition at line 17 of file any.h.

◆ atomic()

template<class T , class... Args>
std::atomic<T> scl::tools::make::atomic ( Args &&...  args)
inline

Creates an atomic in-place with the given set of arguments.

Template Parameters
Tbeing the value type of the atomic to create
Argsbeing the arguments' types
Parameters
argsbeing the arguments to pass to the constructor of the value type
Returns
a std::atomic<T> constructed using the given arguments

Definition at line 18 of file atomic.h.

◆ emptyOptional()

template<class T >
constexpr scl::utils::Optional<T> scl::tools::make::emptyOptional ( )

Creates an empty optional.

Template Parameters
Tbeing the optional's value type
Returns
an Optional<T> initialized with None

Definition at line 28 of file optional.h.

◆ err()

template<class T , class E >
scl::utils::Result<T, E> scl::tools::make::err ( const E &  error)

Definition at line 15 of file result.h.

◆ from()

template<class T , class... Args>
T scl::tools::make::from ( Args &&...  args)
inline

Instantiate the given value type in-place with the given set of arguments.

Template Parameters
Tbeing the value type to instantiate
Argsbeing the arguments' types
Parameters
argsbeing the arguments to pass to the constructor of the value type
Returns
a T constructed using the given arguments

Definition at line 16 of file from.h.

◆ mutexed()

template<class T , class... Args>
scl::async::Mutexed<T> scl::tools::make::mutexed ( Args &&...  args)

Creates a scl::async::Mutexed from the given type and arguments.

Template Parameters
Tbeing the type of values wrapped by the Mutexed
Argsbeing the types of the arguments passed to the constructor
Parameters
argsbeing the arguments passed to the constructor
Returns
an initialized Mutexed

Definition at line 15 of file mutexed.h.

◆ none()

template<class T >
constexpr scl::utils::Optional<T> scl::tools::make::none ( )

Alias for scl::tools::make::emptyOptional.

Definition at line 44 of file optional.h.

◆ ok()

template<class T , class E = scl::utils::Placeholder>
scl::utils::Result<T, E> scl::tools::make::ok ( const T &  value)

Definition at line 10 of file result.h.

◆ optional()

template<class T , class... Args>
constexpr scl::utils::Optional<T> scl::tools::make::optional ( Args &&...  args)

Creates an scl::utils::Optional with a constructed value.

Template Parameters
Tbeing the optional's value type
Argsbeing the arguments' types
Parameters
argsbeing the arguments passed to the constructor of the value type
Returns
an Optional<T> constructed with the given arguments

Definition at line 18 of file optional.h.

◆ optionalFromPointer()

template<class T >
constexpr scl::utils::Optional<T> scl::tools::make::optionalFromPointer ( const T *  ptr)

Creates an optional from a pointer.

Template Parameters
Tbeing the value type of the Optional
Parameters
ptrbeing the pointer to construct from
Returns
an empty optional if null, an initialized optional otherwise

Definition at line 55 of file optional.h.

◆ promise()

template<class T , class... Args>
std::promise<T> scl::tools::make::promise ( Args &&...  args)
inline

Creates a fulfilled std::promise in-place with the given set of arguments.

Template Parameters
Tbeing the value type of the fulfilled std::promise to create
Argsbeing the arguments' types
Parameters
argsbeing the arguments to pass to the constructor of the value type
Returns
a fulfilled std::promise<T> constructed using the given arguments

Definition at line 17 of file promise.h.

◆ ptr()

template<class T , class... Args>
T* scl::tools::make::ptr ( Args &&...  args)
inline

Creates a pointer in-place with the given set of arguments (using new)

Template Parameters
Tbeing the value type of the pointer to create
Argsbeing the arguments' types
Parameters
argsbeing the arguments to pass to the constructor of the value type
Returns
a T* constructed using the given arguments

Definition at line 16 of file ptr.h.

◆ shared()

template<class T , class... Args>
std::shared_ptr<T> scl::tools::make::shared ( Args &&...  args)

Creates a shared_ptr in-place with the given set of arguments.

Template Parameters
Tbeing the value type of the shared_ptr to create
Argsbeing the arguments' types
Parameters
argsbeing the arguments to pass to the constructor of the value type
Returns
a std::shared_ptr<T> constructed using the given arguments

Definition at line 17 of file shared.h.

◆ some()

template<class T , class... Args>
constexpr scl::utils::Optional<T> scl::tools::make::some ( Args &&...  args)

Alias for scl::tools::make::optional.

Definition at line 36 of file optional.h.

◆ unique()

template<class T , class... Args>
std::unique_ptr<T> scl::tools::make::unique ( Args &&...  args)

Creates a unique_ptr in-place with the given set of arguments.

Template Parameters
Tbeing the value type of the unique_ptr to create
Argsbeing the arguments' types
Parameters
argsbeing the arguments to pass to the constructor of the value type
Returns
a std::unique_ptr<T> constructed using the given arguments

Definition at line 17 of file unique.h.