staticlib_support  1.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Namespaces | Classes | Functions
staticlib::support Namespace Reference

Namespaces

namespace  detail_defer
namespace  logic

Classes

class  exception
 Base exception class for various exceptions in staticlib modules. More...
class  bad_observed_pointer_access_exception
 Observer-specific exception. More...
class  observer_ptr
 Non-owning pointer. More...
class  bad_optional_access_exception
 Optional-specific exception. More...
class  optional
 Basic implementation of optional, reference impl ( https://github.com/akrzemi1/Optional ) cannot be used, as it doesn't support MSVC2013. More...
class  release_deleter
 Deleter implementation for std::shared_ptr that allows to release the owned object from shared_ptr More...

Functions

template<typename T >
detail_defer::defer_guard< T > defer (T func)
 Creates a "guard object", that will execute specified lambda function on destruction.
template<typename T >
std::enable_if
< std::is_unsigned< T >::value,
bool >::type 
is_int32 (T val)
 Checks that specified unsigned integer lies between <int32_t>::min() and <int32_t>::max()
template<typename T >
std::enable_if
< std::is_unsigned< T >::value,
bool >::type 
is_uint32 (T val)
 Checks that specified unsigned integer lies between 0 (inclusive) and <uint32_t>::max()
template<typename T >
bool is_uint32_positive (T val)
 Checks that specified integer lies between 0 (exclusive) and <uint32_t>::max()
template<typename T >
std::enable_if
< std::is_unsigned< T >::value,
bool >::type 
is_int16 (T val)
 Checks that specified unsigned integer lies between <int16_t>::min() and <int16_t>::max()
template<typename T >
std::enable_if
< std::is_unsigned< T >::value,
bool >::type 
is_uint16 (T val)
 Checks that specified unsigned integer lies between 0 (inclusive) and <uint16_t>::max()
template<typename T >
bool is_uint16_positive (T val)
 Checks that specified integer lies between 0 (exclusive) and <uint16_t>::max()
template<typename T >
std::enable_if
< std::is_unsigned< T >::value,
bool >::type 
is_int64 (T val)
 Checks that specified unsigned integer lies between <int64_t>::min() and <int64_t>::max()
template<typename T >
std::enable_if
< std::is_unsigned< T >::value,
bool >::type 
is_uint64 (T val)
 Checks that specified unsigned integer lies between 0 (inclusive) and <uint64_t>::max()
template<typename T >
bool is_uint64_positive (T val)
 Checks that specified integer lies between 0 (exclusive) and <uint64_t>::max()
template<typename T >
std::enable_if
< std::is_unsigned< T >::value,
bool >::type 
is_streamsize (T val)
 Checks that specified unsigned integer lies between <streamsize>::min() and <streamsize>::max()
template<typename T >
std::enable_if
< std::is_unsigned< T >::value,
bool >::type 
is_sizet (T val)
 Checks that specified unsigned integer lies between 0 (inclusive) and <size_t>::max()
template<typename T >
bool is_sizet_positive (T val)
 Checks that specified integer lies between 0 (exclusive) and <uint32_t>::max()
template<typename T , typename... Args>
std::unique_ptr< T > make_unique (Args &&...args)
 Shortcut template for creating std::unique_ptr, see details.
template<typename T >
observer_ptr< T > make_observer_ptr (T *target)
 Helper function, constructs new observer instance.
template<typename T >
observer_ptr< T > make_observer_ptr (T &target)
 Helper function, constructs new observer instance.
template<typename T >
optional< T > make_optional (T &&value)
 Helper function, constructs optional instance.
template<typename T >
std::shared_ptr< T > make_shared_with_release_deleter (T *ptr)
template<typename T >
std::unique_ptr< T > make_unique_from_shared_with_release_deleter (std::shared_ptr< T > ptr)
template<typename T >
std::string to_string_any (const T &obj)
 Generic to_string implementation.
template<typename T >
std::string to_string (const T &obj)
 Generic to_string implementation, already exists as std::to_string in most C++11 compilers except GCC 4.8 on Android.
std::string to_string_bool (bool val)
 Converts bool value to "true" or "false" string.

Function Documentation

template<typename T >
detail_defer::defer_guard<T> staticlib::support::defer ( T  func)

Creates a "guard object", that will execute specified lambda function on destruction.

Similar in nature with GSL's finally.

Parameters
funclambda function to execute on destruction, must be "noexcept"
Returns
guard object
template<typename T >
std::enable_if<!std::is_unsigned< T >::value, bool >::type staticlib::support::is_int16 ( T  val)

Checks that specified unsigned integer lies between <int16_t>::min() and <int16_t>::max()

Checks that specified signed integer lies between <int16_t>::min() and <int16_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
std::enable_if<!std::is_unsigned< T >::value, bool >::type staticlib::support::is_int32 ( T  val)

Checks that specified unsigned integer lies between <int32_t>::min() and <int32_t>::max()

Checks that specified signed integer lies between <int32_t>::min() and <int32_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
std::enable_if<!std::is_unsigned< T >::value, bool >::type staticlib::support::is_int64 ( T  val)

Checks that specified unsigned integer lies between <int64_t>::min() and <int64_t>::max()

Checks that specified signed integer lies between <int64_t>::min() and <int64_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
std::enable_if<!std::is_unsigned< T >::value, bool >::type staticlib::support::is_sizet ( T  val)

Checks that specified unsigned integer lies between 0 (inclusive) and <size_t>::max()

Checks that specified signed integer lies between 0 (inclusive) and <size_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
bool staticlib::support::is_sizet_positive ( T  val)

Checks that specified integer lies between 0 (exclusive) and <uint32_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
std::enable_if<!std::is_unsigned< T >::value, bool >::type staticlib::support::is_streamsize ( T  val)

Checks that specified unsigned integer lies between <streamsize>::min() and <streamsize>::max()

Checks that specified signed integer lies between <streamsize>::min() and <streamsize>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
std::enable_if<!std::is_unsigned< T >::value, bool >::type staticlib::support::is_uint16 ( T  val)

Checks that specified unsigned integer lies between 0 (inclusive) and <uint16_t>::max()

Checks that specified signed integer lies between 0 (inclusive) and <uint16_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
bool staticlib::support::is_uint16_positive ( T  val)

Checks that specified integer lies between 0 (exclusive) and <uint16_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
std::enable_if<!std::is_unsigned< T >::value, bool >::type staticlib::support::is_uint32 ( T  val)

Checks that specified unsigned integer lies between 0 (inclusive) and <uint32_t>::max()

Checks that specified signed integer lies between 0 (inclusive) and <uint32_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
bool staticlib::support::is_uint32_positive ( T  val)

Checks that specified integer lies between 0 (exclusive) and <uint32_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
std::enable_if<!std::is_unsigned< T >::value, bool >::type staticlib::support::is_uint64 ( T  val)

Checks that specified unsigned integer lies between 0 (inclusive) and <uint64_t>::max()

Checks that specified signed integer lies between 0 (inclusive) and <uint64_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
bool staticlib::support::is_uint64_positive ( T  val)

Checks that specified integer lies between 0 (exclusive) and <uint64_t>::max()

Parameters
valinteger
Returns
true if check successful, false otherwise
template<typename T >
observer_ptr<T> staticlib::support::make_observer_ptr ( T *  target)

Helper function, constructs new observer instance.

Parameters
targettarget pointer
Returns
observer instance
template<typename T >
observer_ptr<T> staticlib::support::make_observer_ptr ( T &  target)

Helper function, constructs new observer instance.

Parameters
targettarget reference
Returns
observer instance
template<typename T >
optional<T> staticlib::support::make_optional ( T &&  value)

Helper function, constructs optional instance.

Parameters
valuevalue to store
Returns
optional instance
template<typename T >
std::shared_ptr<T> staticlib::support::make_shared_with_release_deleter ( T *  ptr)
template<typename T , typename... Args>
std::unique_ptr<T> staticlib::support::make_unique ( Args &&...  args)

Shortcut template for creating std::unique_ptr, see details.

Becomes obsolete with C++14.

Parameters
argspointer object constructor arguments
Returns
smart pointer to created object
template<typename T >
std::unique_ptr<T> staticlib::support::make_unique_from_shared_with_release_deleter ( std::shared_ptr< T >  ptr)
template<typename T >
std::string staticlib::support::to_string ( const T &  obj)

Generic to_string implementation, already exists as std::to_string in most C++11 compilers except GCC 4.8 on Android.

Parameters
objobject to stringify
Returns
string representation of specified value
template<typename T >
std::string staticlib::support::to_string_any ( const T &  obj)

Generic to_string implementation.

Parameters
objobject to stringify
Returns
string representation of specified value
std::string staticlib::support::to_string_bool ( bool  val)
inline

Converts bool value to "true" or "false" string.

Parameters
valboolean value
Returns
"true" or "false" string