library of assembled shared sources

http://lass.cocamware.com

lass::stde::triple< T1, T2, T3 > Class Template Reference

extension of std::pair to three values, trait three values as a single unit. More...

#include <triple.h>


Public Types

typedef T1 first_type
typedef T2 second_type
typedef T3 third_type

Public Member Functions

 triple ()
 default constructor The default constructor creates a vlaue triple with triples that are initialized by the default constructor of their type.
 triple (typename util::CallTraits< T1 >::TParam a, typename util::CallTraits< T2 >::TParam b, typename util::CallTraits< T3 >::TParam c)
 constructor for three values
template<typename U1 , typename U2 , typename U3 >
 triple (const triple< U1, U2, U3 > &other)
 copy constructor with implicit conversions This template version of the copy constructor provided here is ussed when implicit conversions are necessary.

Data Fields

T1 first
T2 second
T3 third

Related Functions

(Note that these are not member functions.)

template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator== (const triple< T1, T2, T3 > &x, const triple< U1, U2, U3 > &y)
 two triples are identical if all elements (first, second, third) are identical.
template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator< (const triple< T1, T2, T3 > &x, const triple< U1, U2, U3 > &y)
 return true if x is "less" than y.
template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator!= (const triple< T1, T2, T3 > &x, const triple< U1, U2, U3 > &y)
 equivalent to !(x == y), see operator<
template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator> (const triple< T1, T2, T3 > &x, const triple< U1, U2, U3 > &y)
 equivalent to y < x, see operator<
template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator<= (const triple< T1, T2, T3 > &x, const triple< U1, U2, U3 > &y)
 equivalent to !(y < x), see operator<
template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator>= (const triple< T1, T2, T3 > &x, const triple< U1, U2, U3 > &y)
 equivalent to !(x < y), see operator<
template<typename T1 , typename T2 , typename T3 >
triple< T1, T2, T3 > make_triple (const T1 &a, const T2 &b, const T3 &c)
 convenience function to create a lass::stde::triple.


Detailed Description

template<typename T1, typename T2, typename T3>
class lass::stde::triple< T1, T2, T3 >

extension of std::pair to three values, trait three values as a single unit.

Author:
Bram de Greve [Bramz]
we'd like to refer to the C++ standard library for info on std::pair. triple is an extension of this to three values. As std::pair, triple is declared as a struct, the default constructor will initialize all elements with their default constructor, and implicit conversions between triples of different type are allowed, provided that the conversions between the element types are possible.

As for std::pair, the "less than" comparison is implemented for triple in a similar way. The first value has higher priority than the second and third, and the second value has higher priority than the third. Thus, if the first values of two pairs differ, the result of their comparison is used as the result of the comparison of the whole triples. If the first values are equal, the comparison of the second values yields the result if they differ. If the second values are equal too, the comparison of the third values finally yields the result.

Definition at line 72 of file triple.h.


Member Typedef Documentation

template<typename T1 , typename T2 , typename T3 >
typedef T1 lass::stde::triple< T1, T2, T3 >::first_type

Definition at line 74 of file triple.h.

template<typename T1 , typename T2 , typename T3 >
typedef T2 lass::stde::triple< T1, T2, T3 >::second_type

Definition at line 75 of file triple.h.

template<typename T1 , typename T2 , typename T3 >
typedef T3 lass::stde::triple< T1, T2, T3 >::third_type

Definition at line 76 of file triple.h.


Constructor & Destructor Documentation

template<typename T1 , typename T2 , typename T3 >
lass::stde::triple< T1, T2, T3 >::triple (  )  [inline]

default constructor The default constructor creates a vlaue triple with triples that are initialized by the default constructor of their type.

Because of language rules, an explicit call of a default constructor also initializes fundamental data types such as int.

Definition at line 57 of file triple.inl.

template<typename T1 , typename T2 , typename T3 >
lass::stde::triple< T1, T2, T3 >::triple ( typename util::CallTraits< T1 >::TParam  a,
typename util::CallTraits< T2 >::TParam  b,
typename util::CallTraits< T3 >::TParam  c 
) [inline]

constructor for three values

Definition at line 69 of file triple.inl.

template<typename T1 , typename T2 , typename T3 >
template<typename U1 , typename U2 , typename U3 >
lass::stde::triple< T1, T2, T3 >::triple ( const triple< U1, U2, U3 > &  other  )  [inline]

copy constructor with implicit conversions This template version of the copy constructor provided here is ussed when implicit conversions are necessary.

If an object of type Triple gets copied, the normal implicitly generated default copy constructor is called, which is nice.

Definition at line 87 of file triple.inl.


Friends And Related Function Documentation

template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator== ( const triple< T1, T2, T3 > &  x,
const triple< U1, U2, U3 > &  y 
) [related]

two triples are identical if all elements (first, second, third) are identical.

Definition at line 110 of file triple.inl.

References lass::stde::triple< T1, T2, T3 >::first, lass::stde::triple< T1, T2, T3 >::second, and lass::stde::triple< T1, T2, T3 >::third.

template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator< ( const triple< T1, T2, T3 > &  x,
const triple< U1, U2, U3 > &  y 
) [related]

return true if x is "less" than y.

As for std::pair, the "less than" comparison is implemented for Triples in a similar way. The first value has higher priority than the second and third, and the second value has higher priority than the third. Thus, if the first values of two pairs differ, the result of their comparison is used as the result of the comparison of the whole triples. If the first values are equal, the comparison of the second values yields the result if they differ. If the second values are equal too, the comparison of the third values finally yields the result.

Definition at line 126 of file triple.inl.

template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator!= ( const triple< T1, T2, T3 > &  x,
const triple< U1, U2, U3 > &  y 
) [related]

equivalent to !(x == y), see operator<

Definition at line 136 of file triple.inl.

template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator> ( const triple< T1, T2, T3 > &  x,
const triple< U1, U2, U3 > &  y 
) [related]

equivalent to y < x, see operator<

Definition at line 145 of file triple.inl.

template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator<= ( const triple< T1, T2, T3 > &  x,
const triple< U1, U2, U3 > &  y 
) [related]

equivalent to !(y < x), see operator<

Definition at line 154 of file triple.inl.

template<typename T1 , typename T2 , typename T3 , typename U1 , typename U2 , typename U3 >
bool operator>= ( const triple< T1, T2, T3 > &  x,
const triple< U1, U2, U3 > &  y 
) [related]

equivalent to !(x < y), see operator<

Definition at line 163 of file triple.inl.

template<typename T1 , typename T2 , typename T3 >
triple< T1, T2, T3 > make_triple ( const T1 &  a,
const T2 &  b,
const T3 &  c 
) [related]

convenience function to create a lass::stde::triple.

The make_triple template function enables you to create a value triple without writing the types explicitly. In particular the make_triple function makes it convenient to pass three values of a triple directly to a function that requires a triple as its argument. It works even when the types do not match exactly becuase the template copy constructor provides implicit type conversion.

using make_triple should cost no runtime. The compiler should always optimize any implied overhead.

Definition at line 194 of file triple.inl.


Field Documentation

template<typename T1 , typename T2 , typename T3 >
T1 lass::stde::triple< T1, T2, T3 >::first

Definition at line 78 of file triple.h.

Referenced by lass::stde::triple< T1, T2, T3 >::operator==().

template<typename T1 , typename T2 , typename T3 >
T2 lass::stde::triple< T1, T2, T3 >::second

Definition at line 79 of file triple.h.

Referenced by lass::stde::triple< T1, T2, T3 >::operator==().

template<typename T1 , typename T2 , typename T3 >
T3 lass::stde::triple< T1, T2, T3 >::third

Definition at line 80 of file triple.h.

Referenced by lass::stde::triple< T1, T2, T3 >::operator==().


The documentation for this class was generated from the following files:

Generated on Mon Nov 10 14:22:16 2008 for Library of Assembled Shared Sources by doxygen 1.5.7.1
SourceForge.net Logo