2.10.0
Freundlich's C++ toolkit
Classes | Macros | Typedefs | Enumerations | Functions | Variables
fcppt.various

Description

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...
 
class  fcppt::homogenous_pair< T >
 A pair like std::pair with both elements of the same type. 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::no_init
 A dummy struct to use a constructor that does not initialize. 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. More...
 
#define FCPPT_CHECK_LITERAL_CONVERSION(dest, source)
 Checks if a literal conversion is safe. More...
 
#define FCPPT_MAIN   FCPPT_DETAIL_MAIN
 The name of the main function. More...
 
#define FCPPT_NONCOPYABLE(classname)
 Makes a class noncopyable. More...
 
#define FCPPT_USE(name)
 Uses an argument. More...
 

Typedefs

typedef char fcppt::args_char
 The char type of the main function. More...
 
typedef fcppt::iterator::range< fcppt::args_vector::const_iterator > fcppt::args_range
 A view over command line arguments. More...
 
typedef std::vector< fcppt::stringfcppt::args_vector
 A vector of command line arguments. More...
 
typedef fcppt::version_integral_c< FCPPT_VERSION/100000UL > fcppt::major_version
 fcppt's major version More...
 
typedef fcppt::version_integral_c< FCPPT_VERSION % 1000 > fcppt::micro_version
 fcppt's micro version More...
 
typedef fcppt::version_integral_c<(FCPPT_VERSION/1000) % 1000 > fcppt::minor_version
 fcppt's minor version More...
 
template<typename Type >
using fcppt::tag_type = typename fcppt::detail::tag_type< fcppt::type_traits::remove_cv_ref_t< Type > >::type
 Extracts the type of fcppt::tag. More...
 
typedef unsigned long fcppt::version_int
 The int type to use for a version component. More...
 
template<fcppt::version_int Value>
using fcppt::version_integral_c = std::integral_constant< fcppt::version_int, Value >
 An integral constant for a version component. More...
 

Enumerations

enum  fcppt::loop { fcppt::loop::break_, fcppt::loop::continue_ }
 Denotes a loop control statement. More...
 

Functions

template<typename T >
fcppt::absurd ()
 The polymorphic terminate function. More...
 
FCPPT_DETAIL_SYMBOL fcppt::args_vector fcppt::args (int argc, fcppt::args_char const *const *argv)
 Copy main arguments into a container. More...
 
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. More...
 
template<typename Type >
fcppt::detail::const_< Type > fcppt::const_ (Type _value)
 Function returning a constant. More...
 
template<typename Type >
Type fcppt::copy (Type const &_value)
 Copies a value. More...
 
FCPPT_DETAIL_SYMBOL fcppt::optional_std_string fcppt::getenv (std::string const &)
 Gets an optional value from the environment. More...
 
template<typename Type >
std::size_t fcppt::hash (Type const &_value)
 Calls std::hash. More...
 
std::size_t fcppt::hash_combine (std::size_t const _hash_old, std::size_t const _hash_new)
 Combines two hashes. More...
 
template<typename T >
bool fcppt::operator< (fcppt::homogenous_pair< T > const &_left, fcppt::homogenous_pair< T > const &_right)
 Compares two homogenous pairs lexicographically. More...
 
template<typename T >
bool fcppt::operator== (fcppt::homogenous_pair< T > const &_left, fcppt::homogenous_pair< T > const &_right)
 Compares two homogenous pairs for equality. More...
 
template<typename T >
bool fcppt::operator!= (fcppt::homogenous_pair< T > const &_left, fcppt::homogenous_pair< T > const &_right)
 Compares two homogenous pairs for equality. More...
 
template<typename T , typename Ch , typename Traits >
std::basic_ostream< Ch, Traits > & fcppt::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::homogenous_pair< T > const &_pair)
 Writes a pair to an ostream. More...
 
template<typename Type1 , typename Type2 >
fcppt::homogenous_pair< fcppt::type_traits::remove_cv_ref_t< Type1 >> fcppt::make_homogenous_pair (Type1 &&_first, Type2 &&_second)
 Like std::make_pair for fcppt::homogenous_pair. More...
 
template<typename Int >
fcppt::int_range< Int > fcppt::make_int_range (Int const _begin, Int const _end)
 Creates a forward integer range. More...
 
template<typename Int >
fcppt::int_range< Int > fcppt::make_int_range_count (Int const _count)
 Creates a forward integer range starting at zero. More...
 
template<typename Type >
Type fcppt::move_clear (Type &_value)
 Moves out of a value and clears it. More...
 
template<bool Cond, typename Arg >
decltype(auto) fcppt::move_if (Arg &&_arg)
 Moves an object if a condition is true. More...
 
template<typename Type , typename Arg >
decltype(auto) fcppt::move_if_rvalue (Arg &&_arg)
 Moves an object if a type is an rvalue. More...
 
constexpr bool fcppt::not_ (bool const _value)
 Boolean not. More...
 
FCPPT_DETAIL_SYMBOL std::string fcppt::type_name (char const *)
 Returns a demangled type name if possible. More...
 
FCPPT_DETAIL_SYMBOL std::string fcppt::type_name_from_index (std::type_index const &)
 Returns a demangled type name if possible. More...
 
FCPPT_DETAIL_SYMBOL std::string fcppt::type_name_from_info (std::type_info const &)
 Returns a demangled type name if possible. More...
 
bool fcppt::operator== (fcppt::unit const &, fcppt::unit const &)
 Compares units for equality. More...
 
bool fcppt::operator!= (fcppt::unit const &, fcppt::unit const &)
 Compares units for inequality. More...
 
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. More...
 
FCPPT_DETAIL_SYMBOL fcppt::string fcppt::version_string ()
 fcppt's version as a string More...
 
FCPPT_OPTIONS_DETAIL_SYMBOL fcppt::string fcppt::options::indent (fcppt::string &&)
 Indents every line of a string once. More...
 

Variables

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. More...
 

Macro Definition Documentation

◆ FCPPT_ASSERT_COMPLETE

#define FCPPT_ASSERT_COMPLETE (   type)
Value:
static_assert(\
sizeof(type) > 0,\
"Type must be complete" \
)

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.

template<
typename T
>
void
std_delete(
T *const _param
)
{
T
);
delete _param;
}

◆ FCPPT_CHECK_LITERAL_CONVERSION

#define FCPPT_CHECK_LITERAL_CONVERSION (   dest,
  source 
)
Value:
static_assert(\
!std::is_same<\
source,\
bool\
>::value \
&& \
!(\
std::is_integral<\
dest\
>::value \
&& \
std::is_floating_point<\
source\
>::value\
),\
"A literal conversion from bool, or from floating point to int is not allowed!"\
)

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.

◆ FCPPT_MAIN

#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 **).

Note
This must be used together with FCPPT_UTILS_MAIN_COMPILE_OPTIONS and FCPPT_UTILS_MAIN_LINK_LIBS.

◆ FCPPT_NONCOPYABLE

#define FCPPT_NONCOPYABLE (   classname)
Value:
FCPPT_DETAIL_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.

By default, C++ generates a copy constructor and assignment operator for every class where this is possible (when its elements can all be copy constructed and assigned). However, this is not a good default in a lot of situations where it can be dangerous to copy an object:

  • If a class has already a non trivial constructor or destructor, for example when it has to manage dynamic resources or it implements some scoped behaviour, like for example a scoped_lock.

  • If an object of a class in a hierarchy gets copied, the object will be sliced and not cloned. Therefore, it is often advisable to make all classes in a hierarchy noncopyable.
class test_noncopyable
{
test_noncopyable
);
public:
test_noncopyable()
:
ptr_(new int(42))
{
}
~test_noncopyable()
{
delete ptr_;
}
private:
int *ptr_;
};
Parameters
classnameThe name of the class

◆ FCPPT_USE

#define FCPPT_USE (   name)
Value:
static_cast<\
void\
>(\
name\
)

Uses an argument.

This is useful in situations where an argument is only used for its type.

Typedef Documentation

◆ args_char

typedef char fcppt::args_char

The char type of the main function.

◆ args_range

typedef fcppt::iterator::range< fcppt::args_vector::const_iterator> fcppt::args_range

A view over command line arguments.

◆ args_vector

typedef std::vector< fcppt::string> fcppt::args_vector

A vector of command line arguments.

◆ major_version

typedef fcppt::version_integral_c< FCPPT_VERSION / 100000UL> fcppt::major_version

fcppt's major version

◆ micro_version

typedef fcppt::version_integral_c< FCPPT_VERSION % 1000> fcppt::micro_version

fcppt's micro version

◆ minor_version

typedef fcppt::version_integral_c< (FCPPT_VERSION / 1000) % 1000> fcppt::minor_version

fcppt's minor version

◆ tag_type

template<typename Type >
using fcppt::tag_type = typedef typename fcppt::detail::tag_type< fcppt::type_traits::remove_cv_ref_t< Type > >::type

Extracts the type of fcppt::tag.

◆ version_int

typedef unsigned long fcppt::version_int

The int type to use for a version component.

◆ version_integral_c

template<fcppt::version_int Value>
using fcppt::version_integral_c = typedef std::integral_constant< fcppt::version_int, Value >

An integral constant for a version component.

Enumeration Type Documentation

◆ loop

enum fcppt::loop
strong

Denotes a loop control statement.

Used by various algorithms that need the ability to break out of a loop early.

Enumerator
break_ 
continue_ 

Function Documentation

◆ absurd()

template<typename T >
T fcppt::absurd ( )
inline

The polymorphic terminate function.

Terminates the program but can be used where an expression of any type is required.

◆ args()

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.

◆ args_from_second()

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.

◆ const_()

template<typename Type >
fcppt::detail::const_< Type> fcppt::const_ ( Type  _value)
inline

Function returning a constant.

◆ copy()

template<typename Type >
Type fcppt::copy ( Type const &  _value)
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.

◆ getenv()

FCPPT_DETAIL_SYMBOL fcppt::optional_std_string fcppt::getenv ( std::string const &  )

Gets an optional value from the environment.

◆ hash()

template<typename Type >
std::size_t fcppt::hash ( Type const &  _value)
inline

Calls std::hash.

◆ hash_combine()

std::size_t fcppt::hash_combine ( std::size_t const  _hash_old,
std::size_t const  _hash_new 
)
inline

Combines two hashes.

◆ indent()

FCPPT_OPTIONS_DETAIL_SYMBOL fcppt::string fcppt::options::indent ( fcppt::string &&  )

Indents every line of a string once.

◆ make_homogenous_pair()

template<typename Type1 , typename Type2 >
fcppt::homogenous_pair< fcppt::type_traits::remove_cv_ref_t< Type1 >> fcppt::make_homogenous_pair ( Type1 &&  _first,
Type2 &&  _second 
)
inline

Like std::make_pair for fcppt::homogenous_pair.

◆ make_int_range()

template<typename Int >
fcppt::int_range< Int> fcppt::make_int_range ( Int const  _begin,
Int const  _end 
)
inline

Creates a forward integer range.

Creates the forward integer range [_begin, _end).

Parameters
_beginThe first element in the range
_endOne past the last element of the range

◆ make_int_range_count()

template<typename Int >
fcppt::int_range< Int> fcppt::make_int_range_count ( Int const  _count)
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.

Parameters
_countThe number of elements in the range

◆ move_clear()

template<typename Type >
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.

Template Parameters
TypeMust be movable and have a default constructor.

◆ move_if()

template<bool Cond, typename Arg >
decltype( auto ) fcppt::move_if ( Arg &&  _arg)
inline

Moves an object if a condition is true.

Moves _arg if Cond is true or Arg is an rvalue.

◆ move_if_rvalue()

template<typename Type , typename Arg >
decltype( auto ) fcppt::move_if_rvalue ( Arg &&  _arg)
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.

◆ not_()

constexpr bool fcppt::not_ ( bool const  _value)
inline

Boolean not.

This function is a replacement for !.

◆ operator!=() [1/2]

bool fcppt::operator!= ( fcppt::unit const &  ,
fcppt::unit const &   
)
inline

Compares units for inequality.

◆ operator!=() [2/2]

template<typename T >
bool fcppt::operator!= ( fcppt::homogenous_pair< T > const &  _left,
fcppt::homogenous_pair< T > const &  _right 
)
inline

Compares two homogenous pairs for equality.

Compares the two pairs _left and _right for equality, using !(_left == _right).

Parameters
_leftThe left operand
_rightThe right operand
Returns
If both pairs are not equal

◆ operator<()

template<typename T >
bool fcppt::operator< ( fcppt::homogenous_pair< T > const &  _left,
fcppt::homogenous_pair< T > const &  _right 
)

Compares two homogenous pairs lexicographically.

Compares the two pairs _left and _right lexicographically. If _left.first and _right.first are equal, which is tested by using !(_left.first < _right.first) && !(_right.first < _left.first) then the result is _left.second < _right.second, otherwise the result is _left.first < _right.first.

Parameters
_leftThe left operand
_rightThe right operand
Returns
If _left is lexicographically less than _right

◆ operator<<() [1/2]

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.

◆ operator<<() [2/2]

template<typename T , typename Ch , typename Traits >
std::basic_ostream< Ch, Traits>& fcppt::operator<< ( std::basic_ostream< Ch, Traits > &  _stream,
fcppt::homogenous_pair< T > const &  _pair 
)

Writes a pair to an ostream.

Writes the pair _pair to _stream, using the formatting (_pair.first, _pair.second).

Parameters
_streamThe stream to write to
_pairThe pair to write
Returns
_stream

◆ operator==() [1/2]

bool fcppt::operator== ( fcppt::unit const &  ,
fcppt::unit const &   
)
inline

Compares units for equality.

◆ operator==() [2/2]

template<typename T >
bool fcppt::operator== ( fcppt::homogenous_pair< T > const &  _left,
fcppt::homogenous_pair< T > const &  _right 
)
inline

Compares two homogenous pairs for equality.

Compares the two pairs _left and _right for equality, using _left.first == _right.first && _left.second == _right.second.

Parameters
_leftThe left operand
_rightThe right operand
Returns
If both pairs are equal

◆ type_name()

FCPPT_DETAIL_SYMBOL std::string fcppt::type_name ( char const *  )

Returns a demangled type name if possible.

◆ type_name_from_index()

FCPPT_DETAIL_SYMBOL std::string fcppt::type_name_from_index ( std::type_index const &  )

Returns a demangled type name if possible.

◆ type_name_from_info()

FCPPT_DETAIL_SYMBOL std::string fcppt::type_name_from_info ( std::type_info const &  )

Returns a demangled type name if possible.

◆ version_string()

FCPPT_DETAIL_SYMBOL fcppt::string fcppt::version_string ( )

fcppt's version as a string

Variable Documentation

◆ move_iterator_if_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)
inline

Makes a move iterator if a type is an rvalue.

Makes a move iterator out of _iterator iff Type is an rvalue.