0.12.0
Freundlich's C++ toolkit
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Types | Public Member Functions | Static Public Member Functions
fcppt::math::dim::object< T, N, S > Class Template Reference

Detailed Description

template<typename T, typename N, typename S>
class fcppt::math::dim::object< T, N, S >

A class representing dynamic or static n-dimensional dimensions.

Template Parameters
TThe dim's value_type
NThe dim's dimension type (this is not necessarily a number!)
SThe dim's storage type

See the module description for more information.

Public Types

typedef N dim_wrapper
 A typedef for the N parameter.
 
typedef S storage_type
 A typedef for the S parameter.
 
typedef math::size_type size_type
 A type that counts the number of elements in a dim.
 
typedef math::difference_type difference_type
 A type that provides the difference between the addresses of two elements in a dim.
 
typedef T value_type
 A type that represents the data type stored in a dim.
 
typedef value_typereference
 A type that provides a reference to an element stored in a dim.
 
typedef value_type const & const_reference
 A type that provides a reference to a const element stored in a dim for reading and performing const operations.
 
typedef T * pointer
 A type that provides a pointer to an element in a dim.
 
typedef T const * const_pointer
 A type that provides a pointer to a const element in a dim.
 
typedef pointer iterator
 A type that provides a random-access iterator that can read or modify any element in a dim.
 
typedef const_pointer const_iterator
 A type that provides a random-access iterator that can read a const element in a dim.
 
typedef std::reverse_iterator
< iterator
reverse_iterator
 A type that provides a random-access iterator that can read or modify any element in a reversed dim.
 
typedef std::reverse_iterator
< const_iterator
const_reverse_iterator
 A type that provides a random-access iterator that can read any const element in the dim.
 

Public Member Functions

 object ()
 Construct an uninitialized dim.
 
 object (storage_type const &s)
 Construct a dim from a storage source.
 
 object (object const &)
 Copy-construct the dim from another dim.
 
template<typename OtherStorage >
 object (object< T, N, OtherStorage > const &)
 Create a dim from a dim with the same dimension and value type but different storage type.
 
template<typename In >
 object (In beg, typename boost::enable_if< type_traits::is_iterator< In >, In >::type end)
 Create a dim and fill it with the contents of the given range.
 
 FCPPT_MATH_DETAIL_MAKE_VARIADIC_CONSTRUCTOR_DECL (FCPPT_MATH_DIM_MAX_CTOR_PARAMS, object) object &operator
 Copy the values from a different dim.
 
template<typename OtherStorage >
objectoperator= (object< T, N, OtherStorage > const &)
 Copy the values from a different dim.
 
 ~object ()
 
objectoperator*= (value_type const &)
 Multiply a dim by a scalar.
 
objectoperator/= (value_type const &)
 Divide a dim by a scalar.
 
reference operator[] (size_type)
 Returns a reference to the dim element at a specified position.
 
const_reference operator[] (size_type) const
 Returns a reference to the dim element at a specified position.
 
reference w ()
 Returns a reference to the first element in the dim.
 
const_reference w () const
 Returns a reference to the first element in the dim.
 
reference h ()
 Returns a reference to the second element in the dim.
 
const_reference h () const
 Returns a reference to the second element in the dim.
 
reference d ()
 Returns a reference to the third element in the dim.
 
const_reference d () const
 Returns a reference to the third element in the dim.
 
value_type content () const
 Returns the area/volume of the dimension.
 
void swap (object &)
 Exchanges the elements of two dims.
 

Static Public Member Functions

static object const null ()
 Returns the dim filled with all zeroes.
 

Member Typedef Documentation

template<typename T, typename N, typename S>
typedef const_pointer fcppt::math::dim::object< T, N, S >::const_iterator

A type that provides a random-access iterator that can read a const element in a dim.

template<typename T, typename N, typename S>
typedef T const* fcppt::math::dim::object< T, N, S >::const_pointer

A type that provides a pointer to a const element in a dim.

template<typename T, typename N, typename S>
typedef value_type const& fcppt::math::dim::object< T, N, S >::const_reference

A type that provides a reference to a const element stored in a dim for reading and performing const operations.

template<typename T, typename N, typename S>
typedef std::reverse_iterator<const_iterator> fcppt::math::dim::object< T, N, S >::const_reverse_iterator

A type that provides a random-access iterator that can read any const element in the dim.

template<typename T, typename N, typename S>
typedef math::difference_type fcppt::math::dim::object< T, N, S >::difference_type

A type that provides the difference between the addresses of two elements in a dim.

template<typename T, typename N, typename S>
typedef N fcppt::math::dim::object< T, N, S >::dim_wrapper

A typedef for the N parameter.

template<typename T, typename N, typename S>
typedef pointer fcppt::math::dim::object< T, N, S >::iterator

A type that provides a random-access iterator that can read or modify any element in a dim.

template<typename T, typename N, typename S>
typedef T* fcppt::math::dim::object< T, N, S >::pointer

A type that provides a pointer to an element in a dim.

template<typename T, typename N, typename S>
typedef value_type& fcppt::math::dim::object< T, N, S >::reference

A type that provides a reference to an element stored in a dim.

template<typename T, typename N, typename S>
typedef std::reverse_iterator<iterator> fcppt::math::dim::object< T, N, S >::reverse_iterator

A type that provides a random-access iterator that can read or modify any element in a reversed dim.

template<typename T, typename N, typename S>
typedef math::size_type fcppt::math::dim::object< T, N, S >::size_type

A type that counts the number of elements in a dim.

template<typename T, typename N, typename S>
typedef S fcppt::math::dim::object< T, N, S >::storage_type

A typedef for the S parameter.

template<typename T, typename N, typename S>
typedef T fcppt::math::dim::object< T, N, S >::value_type

A type that represents the data type stored in a dim.

Constructor & Destructor Documentation

template<typename T , typename N , typename S >
FCPPT_PP_PUSH_WARNING object< T, N, S >::object ( )

Construct an uninitialized dim.

Warning
The content of the dim will be undefined (not null) after initialization
template<typename T , typename N , typename S >
FCPPT_PP_POP_WARNING object< T, N, S >::object ( storage_type const &  s)
explicit

Construct a dim from a storage source.

Parameters
sThe storage source to copy from
template<typename T , typename N , typename S >
object< T, N, S >::object ( object< T, N, S > const &  _other)

Copy-construct the dim from another dim.

template<typename T, typename N, typename S >
template<typename OtherStorage >
FCPPT_PP_PUSH_WARNING object< T, N, S >::object ( object< T, N, OtherStorage > const &  _other)

Create a dim from a dim with the same dimension and value type but different storage type.

Template Parameters
OtherStorageThe other dim's storage type
template<typename T, typename N, typename S >
template<typename In >
object< T, N, S >::object ( In  beg,
typename boost::enable_if< type_traits::is_iterator< In >, In >::type  end 
)

Create a dim and fill it with the contents of the given range.

Template Parameters
Ina forward iterator pointing to elements of type T
Parameters
begThe beginning of the range
endOne past the end of the range
template<typename T , typename N , typename S >
object< T, N, S >::~object ( )

Member Function Documentation

template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S >::value_type object< T, N, S >::content ( ) const

Returns the area/volume of the dimension.

This is equal to the product of all components of the dimension.

template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S >::reference object< T, N, S >::d ( )

Returns a reference to the third element in the dim.

Warning
This will fail at compile-time if N <= 2
template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S >::const_reference object< T, N, S >::d ( ) const

Returns a reference to the third element in the dim.

Warning
This will fail at compile-time if N <= 2
template<typename T, typename N, typename S>
fcppt::math::dim::object< T, N, S >::FCPPT_MATH_DETAIL_MAKE_VARIADIC_CONSTRUCTOR_DECL ( FCPPT_MATH_DIM_MAX_CTOR_PARAMS  ,
object< T, N, S >   
)

Copy the values from a different dim.

template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S >::reference object< T, N, S >::h ( )

Returns a reference to the second element in the dim.

Warning
This will fail at compile-time if N <= 1
template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S >::const_reference object< T, N, S >::h ( ) const

Returns a reference to the second element in the dim.

Warning
This will fail at compile-time if N <= 1
template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S > const object< T, N, S >::null ( )
static

Returns the dim filled with all zeroes.

template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S > & object< T, N, S >::operator*= ( value_type const &  _value)

Multiply a dim by a scalar.

template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S > & object< T, N, S >::operator/= ( value_type const &  _value)

Divide a dim by a scalar.

template<typename T, typename N, typename S>
template<typename OtherStorage >
FCPPT_PP_POP_WARNING fcppt::math::dim::object< T, N, S >::object FCPPT_PP_POP_WARNING fcppt::math::dim::object< T, N, S > & object< T, N, S >::operator= ( object< T, N, OtherStorage > const &  _other)

Copy the values from a different dim.

Template Parameters
OtherStorageThe other dim's storage type
template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S >::reference object< T, N, S >::operator[] ( size_type  _index)

Returns a reference to the dim element at a specified position.

Warning
Behaviour is undefined if the index is out of range.
template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S >::const_reference object< T, N, S >::operator[] ( size_type  _index) const

Returns a reference to the dim element at a specified position.

Warning
Behaviour is undefined if the index is out of range.
template<typename T , typename N , typename S >
void object< T, N, S >::swap ( object< T, N, S > &  _other)

Exchanges the elements of two dims.

template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S >::reference object< T, N, S >::w ( )

Returns a reference to the first element in the dim.

template<typename T , typename N , typename S >
fcppt::math::dim::object< T, N, S >::const_reference object< T, N, S >::w ( ) const

Returns a reference to the first element in the dim.