4.6.0
Freundlich's C++ toolkit
|
Documents smaller features that do not warrant their own modules.
Classes | |
class | fcppt::cyclic_iterator< ContainerIterator > |
An iterator adaptor that cycles through a range. More... | |
class | fcppt::function< Ret(Args...)> |
A function object that cannot be null. More... | |
struct | fcppt::identity |
The identity function. More... | |
class | fcppt::int_iterator< Int > |
An iterator over integers. More... | |
class | fcppt::int_range< Int > |
A forward range over integers. More... | |
struct | fcppt::is_recursive< Type > |
Tests if a type is an fcppt::recursive. More... | |
struct | fcppt::no_init |
A dummy struct to use a constructor that does not initialize. More... | |
struct | fcppt::overloaded< Types > |
Overloads multiple lambdas. More... | |
class | fcppt::recursive< Type > |
Turns an incomplete type into a complete one, allowing recursion. More... | |
struct | fcppt::tag< Type > |
A value for a type name. More... | |
struct | fcppt::unit |
The unit data type. More... | |
Macros | |
#define | FCPPT_ASSERT_COMPLETE(type) |
Assert at compile time that a type is complete. | |
#define | FCPPT_CHAR_LITERAL(_type, _literal) |
A char or wchar_t literal depending on a type. | |
#define | FCPPT_CHECK_LITERAL_CONVERSION(dest, source) |
Checks if a literal conversion is safe. | |
#define | FCPPT_MAIN FCPPT_DETAIL_MAIN |
The name of the main function. | |
#define | FCPPT_NONCOPYABLE(classname) |
Makes a class noncopyable. | |
#define | FCPPT_NONMOVABLE(classname) |
Makes a class nonmovable. | |
#define | FCPPT_STRING_LITERAL(_type, _literal) |
A char or wchar_t string literal depending on a type. | |
#define | FCPPT_USE(name) |
Uses an argument. | |
Typedefs | |
using | fcppt::args_char = fcppt::detail::args_char |
The char type of the main function. | |
using | fcppt::args_range = fcppt::iterator::range<fcppt::args_vector::const_iterator> |
A view over command line arguments. | |
using | fcppt::args_vector = std::vector<fcppt::string> |
A vector of command line arguments. | |
template<typename Arg > | |
using | fcppt::deref_type = decltype(fcppt::deref(std::declval<Arg &>())) |
The type of fcppt::deref. | |
using | fcppt::major_version |
fcppt's major version | |
using | fcppt::micro_version |
fcppt's micro version | |
using | fcppt::minor_version |
fcppt's minor version | |
template<typename Type , typename Arg > | |
using | fcppt::move_if_rvalue_type = decltype(fcppt::move_if_rvalue<Type>(std::declval<Arg>())) |
Type of fcppt::move_if_rvalue. | |
using | fcppt::optional_error_code = fcppt::optional::object<std::error_code> |
An optional error code. | |
template<typename Type > | |
using | fcppt::tag_type = typename fcppt::detail::tag_type<std::remove_cvref_t<Type>>::type |
Extracts the type of fcppt::tag. | |
using | fcppt::version_int |
The int type to use for a version component. | |
template<fcppt::version_int Value> | |
using | fcppt::version_integral_c = std::integral_constant<fcppt::version_int, Value> |
An integral constant for a version component. | |
Enumerations | |
enum class | fcppt::loop : std::uint8_t { fcppt::loop::break_ , fcppt::loop::continue_ } |
Denotes a loop control statement. More... | |
Functions | |
template<typename T > | |
T | fcppt::absurd () |
The polymorphic terminate function. | |
FCPPT_DETAIL_SYMBOL fcppt::args_vector | fcppt::args (int argc, fcppt::args_char const *const *argv) |
Copy main arguments into a container. | |
FCPPT_DETAIL_SYMBOL fcppt::args_vector | fcppt::args_from_second (int argc, fcppt::args_char const *const *argv) |
Copy main arguments into a container, starting from the second. | |
template<typename If , typename Then > | |
std::invoke_result_t< If > | fcppt::cond (bool const _conditional, If const &_if, Then const &_then) |
Functional if-then-else. | |
template<typename Type > | |
fcppt::detail::const_< Type > | fcppt::const_ (Type _value) |
Function returning a constant. | |
template<typename Type > | |
Type | fcppt::copy (Type const &_value) |
Copies a value. | |
template<typename Arg > | |
decltype(auto) | fcppt::deref (Arg &_arg) |
Dereferences an object. | |
FCPPT_DETAIL_SYMBOL fcppt::optional_std_string | fcppt::getenv (std::string_view) |
Gets an optional value from the environment. | |
template<typename Type > | |
std::size_t | fcppt::hash (Type const &_value) |
Calls std::hash. | |
std::size_t | fcppt::hash_combine (std::size_t const _hash_old, std::size_t const _hash_new) |
Combines two hashes. | |
template<typename Ret , typename... Args> | |
fcppt::function< Ret(Args...)> | fcppt::make_function (Ret(&_function)(Args...)) |
Creates an fcppt::function. | |
template<typename Int > | |
fcppt::int_range< Int > | fcppt::make_int_range (Int const _begin, Int const _end) |
Creates a forward integer range. | |
template<typename Int > | |
fcppt::int_range< Int > | fcppt::make_int_range_count (Int const _count) |
Creates a forward integer range starting at zero. | |
FCPPT_DETAIL_SYMBOL fcppt::optional_error_code | fcppt::make_optional_error_code (std::error_code const &error) |
Creates an optional error code. | |
template<typename Type > | |
fcppt::recursive< std::remove_cvref_t< Type > > | fcppt::make_recursive (Type &&_value) |
Creates an fcppt::recursive. | |
template<typename Type > | |
Type | fcppt::move_clear (Type &_value) |
Moves out of a value and clears it. | |
template<bool Cond, typename Arg > | |
decltype(auto) | fcppt::move_if (Arg &&_arg) |
Moves an object if a condition is true. | |
template<typename Type , typename Arg > | |
decltype(auto) | fcppt::move_if_rvalue (Arg &&_arg) |
Moves an object if a type is an rvalue. | |
template<typename Type , typename Iterator > | |
decltype(fcppt::detail::move_iterator_if_rvalue< Type >(std::declval< Iterator const & >())) | fcppt::move_iterator_if_rvalue (Iterator const &_iterator) |
Makes a move iterator if a type is an rvalue. | |
constexpr bool | fcppt::not_ (bool const _value) |
Boolean not. | |
template<typename Arg > | |
fcppt::detail::output< Arg > | fcppt::output (Arg const &_arg) |
Outputs an object. | |
template<typename... Args> | |
fcppt::overloaded< std::remove_cvref_t< Args >... > | fcppt::overload (Args &&..._args) |
Creates an overloaded lambda. | |
template<typename Type > | |
bool | fcppt::operator== (fcppt::recursive< Type > const &_left, fcppt::recursive< Type > const &_right) |
Compares two fcppt::recursive for equality. | |
template<typename Type > | |
bool | fcppt::operator!= (fcppt::recursive< Type > const &_left, fcppt::recursive< Type > const &_right) |
Compares two fcppt::recursive for inequality. | |
template<typename MaxIndex , typename Index , typename Function , typename FailFunction > | |
decltype(auto) | fcppt::runtime_index (Index const _index, Function const &_function, FailFunction const &_fail_function) |
Transforms a runtime index into a an integral constant. | |
FCPPT_DETAIL_SYMBOL std::string | fcppt::type_name (char const *) |
Returns a demangled type name if possible. | |
FCPPT_DETAIL_SYMBOL std::string | fcppt::type_name_from_index (std::type_index const &) |
Returns a demangled type name if possible. | |
FCPPT_DETAIL_SYMBOL std::string | fcppt::type_name_from_info (std::type_info const &) |
Returns a demangled type name if possible. | |
bool | fcppt::operator== (fcppt::unit const &, fcppt::unit const &) |
Compares units for equality. | |
bool | fcppt::operator!= (fcppt::unit const &, fcppt::unit const &) |
Compares units for inequality. | |
template<typename Ch , typename Traits > | |
std::basic_ostream< Ch, Traits > & | fcppt::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::unit const &) |
Outputs a unit to a basic_ostream. | |
FCPPT_DETAIL_SYMBOL std::string | fcppt::version_string () |
fcppt's version as a string | |
#define FCPPT_ASSERT_COMPLETE | ( | type | ) |
Assert at compile time that a type is complete.
In some cases, a type must be complete, which bascially means that it is not void and if it is a class, the definition must already be known. For example, delete
has undefined behaviour if it is invoked on a type that is not complete but has a non trivial destructor.
This macro generates a compile time error if a type is not complete. An example of its usage is shown below.
#define FCPPT_CHAR_LITERAL | ( | _type, | |
_literal ) |
A char or wchar_t literal depending on a type.
If _type is char, then the literal will be of type char
. If _type is wchar_t, then the literal will be of type wchar_t
.
_type | Must be char or wchar_t. |
_literal | Must be a char literal. |
#define FCPPT_CHECK_LITERAL_CONVERSION | ( | dest, | |
source ) |
Checks if a literal conversion is safe.
source must not be a bool
or if dest is integral, then source must not be floating-point.
#define FCPPT_MAIN FCPPT_DETAIL_MAIN |
The name of the main function.
Windows uses wmain
instead of main
for Unicode applications. The type of this function is int (int,fcppt::args_char **)
.
FCPPT_UTILS_MAIN_COMPILE_OPTIONS
and FCPPT_UTILS_MAIN_LINK_LIBS
. #define FCPPT_NONCOPYABLE | ( | classname | ) |
Makes a class noncopyable.
Makes the class called classname noncopyable. The macro must be placed inside the class definition and called with the name of the class. It deletes the copy constructor and the assignment operator. The idea is that the user still implements a move constructor and a move assignment operator. If this is not desired, use FCPPT_NONMOVABLE instead.
classname | The name of the class. |
#define FCPPT_NONMOVABLE | ( | classname | ) |
Makes a class nonmovable.
Makes the class called classname nonmovable and noncopyable. The macro must be placed inside the class definition and called with the name of the class. It deletes the move constructor, the copy constructor, the move assignment operator and the copy assignment operator.
classname | The name of the class. |
#define FCPPT_STRING_LITERAL | ( | _type, | |
_literal ) |
A char or wchar_t string literal depending on a type.
If _type is char, then the literal will be of type char const *
. If _type is wchar_t, then the literal will be of type wchar_t const *
.
_type | Must be char or wchar_t. |
_literal | Must be a string literal. |
#define FCPPT_USE | ( | name | ) |
Uses an argument.
This is useful in situations where an argument is only used for its type.
using fcppt::args_char = fcppt::detail::args_char |
The char type of the main function.
using fcppt::args_range = fcppt::iterator::range<fcppt::args_vector::const_iterator> |
A view over command line arguments.
using fcppt::args_vector = std::vector<fcppt::string> |
A vector of command line arguments.
using fcppt::deref_type = decltype(fcppt::deref(std::declval<Arg &>())) |
The type of fcppt::deref.
using fcppt::major_version |
fcppt's major version
using fcppt::micro_version |
fcppt's micro version
using fcppt::minor_version |
fcppt's minor version
using fcppt::move_if_rvalue_type = decltype(fcppt::move_if_rvalue<Type>(std::declval<Arg>())) |
Type of fcppt::move_if_rvalue.
using fcppt::optional_error_code = fcppt::optional::object<std::error_code> |
An optional error code.
using fcppt::tag_type = typename fcppt::detail::tag_type<std::remove_cvref_t<Type>>::type |
Extracts the type of fcppt::tag.
using fcppt::version_int |
The int type to use for a version component.
using fcppt::version_integral_c = std::integral_constant<fcppt::version_int, Value> |
An integral constant for a version component.
|
strong |
|
inline |
The polymorphic terminate function.
Terminates the program but can be used where an expression of any type is required.
FCPPT_DETAIL_SYMBOL fcppt::args_vector fcppt::args | ( | int | argc, |
fcppt::args_char const *const * | argv ) |
Copy main arguments into a container.
This function is only useful for command line arguments received in main
. To handle Windows arguments, see the GetCommandLine
function.
FCPPT_DETAIL_SYMBOL fcppt::args_vector fcppt::args_from_second | ( | int | argc, |
fcppt::args_char const *const * | argv ) |
Copy main arguments into a container, starting from the second.
|
inline |
Functional if-then-else.
Unlike the ? :
operator, this function does no implicit conversions.
The functions If and Then must return the same type R
.
If | A function callable as R () . |
Then | A function callable as R () . |
|
inline |
Function returning a constant.
|
inline |
Copies a value.
This function is useful in case you need to make an explicit copy of a value but don't want to write down its type.
|
inline |
Dereferences an object.
Calls fcppt::deref_impl::execute to dereference _arg.
FCPPT_DETAIL_SYMBOL fcppt::optional_std_string fcppt::getenv | ( | std::string_view | ) |
Gets an optional value from the environment.
std::getenv
which is not thread-safe. You must ensure that this function is not called concurrently with any function that modifies the environment.
|
inline |
Calls std::hash.
|
inlinenodiscard |
Combines two hashes.
fcppt::function< Ret(Args...)> fcppt::make_function | ( | Ret(&)(Args...) | _function | ) |
Creates an fcppt::function.
|
inline |
Creates a forward integer range.
Creates the forward integer range [_begin, _end).
_begin | The first element in the range |
_end | One past the last element of the range |
|
inline |
Creates a forward integer range starting at zero.
Creates the forward integer range [0, _count). The purpose of this class is to create integer ranges over integer-like types (not just fundamental integers), for example strong typedefs of integers.
_count | The number of elements in the range |
FCPPT_DETAIL_SYMBOL fcppt::optional_error_code fcppt::make_optional_error_code | ( | std::error_code const & | error | ) |
Creates an optional error code.
If error has an error value, then it is returned as an optional. Otherwise, the empty optional is returned.
fcppt::recursive< std::remove_cvref_t< Type > > fcppt::make_recursive | ( | Type && | _value | ) |
Creates an fcppt::recursive.
Type fcppt::move_clear | ( | Type & | _value | ) |
Moves out of a value and clears it.
Certain types can be moved out of but are then left in an unspecific state that only allows them to be destroyed or assigned. This function first moves out of the value and then assigns a default constructed value. For example, this function can be used to move out of a container and leave an empty container behind.
Type | Must be movable and have a default constructor. |
|
inline |
Moves an object if a condition is true.
Moves _arg if Cond is true or Arg is an rvalue.
|
inline |
Moves an object if a type is an rvalue.
Moves _arg if Type is an rvalue or if Arg is an rvalue. The behavior is similar to std::forward
except that this function depends on two types instead of one. This can be useful in situations where you want to move a member if the surrounding object is an rvalue.
|
inline |
Makes a move iterator if a type is an rvalue.
Makes a move iterator out of _iterator iff Type is an rvalue.
|
constexpr |
Boolean not.
This function is a replacement for !
.
bool fcppt::operator!= | ( | fcppt::recursive< Type > const & | _left, |
fcppt::recursive< Type > const & | _right ) |
Compares two fcppt::recursive for inequality.
|
inline |
Compares units for inequality.
|
inline |
Outputs a unit to a basic_ostream.
bool fcppt::operator== | ( | fcppt::recursive< Type > const & | _left, |
fcppt::recursive< Type > const & | _right ) |
Compares two fcppt::recursive for equality.
|
inline |
Compares units for equality.
|
inline |
Outputs an object.
Calls fcppt::output_impl::execute to output _arg. The default implementation uses operator<<
.
fcppt::overloaded< std::remove_cvref_t< Args >... > fcppt::overload | ( | Args &&... | _args | ) |
Creates an overloaded lambda.
|
inline |
Transforms a runtime index into a an integral constant.
Passes _index as an integral constant to _function if _index is less than MaxIndex::value, and returns its result. Otherwise, the result of _fail_function is returned.
Index | An unsigned integer type. |
MaxIndex | An integral constant with element type Index. |
Function | A function callable as R (std::integral_constant<Index,N>) for every N of type Index, where R is the result type. |
FailFunction | A function callable as R() , where R is the result type. |
FCPPT_DETAIL_SYMBOL std::string fcppt::type_name | ( | char const * | ) |
Returns a demangled type name if possible.
FCPPT_DETAIL_SYMBOL std::string fcppt::type_name_from_index | ( | std::type_index const & | ) |
Returns a demangled type name if possible.
FCPPT_DETAIL_SYMBOL std::string fcppt::type_name_from_info | ( | std::type_info const & | ) |
Returns a demangled type name if possible.
FCPPT_DETAIL_SYMBOL std::string fcppt::version_string | ( | ) |
fcppt's version as a string