/usr/include/boost/icl/detail
Edit: /usr/include/boost/icl/detail/mapped_reference.hpp (7169B)
/*-----------------------------------------------------------------------------+
Copyright (c) 2009-2009: Joachim Faulhaber
+------------------------------------------------------------------------------+
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENCE.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
+-----------------------------------------------------------------------------*/
#ifndef BOOST_ICL_DETAIL_MAPPED_REFERENCE_HPP_JOFA_091108
#define BOOST_ICL_DETAIL_MAPPED_REFERENCE_HPP_JOFA_091108
#include
#include
#include
#include
namespace boost{namespace icl
{
template class mapped_reference;
//------------------------------------------------------------------------------
template
struct is_mapped_reference_combinable{
typedef is_mapped_reference_combinable type;
BOOST_STATIC_CONSTANT(bool, value = false);
};
template
struct is_mapped_reference_combinable >
{
typedef is_mapped_reference_combinable > type;
BOOST_STATIC_CONSTANT(bool, value = true);
};
template
struct is_mapped_reference_combinable >
{
typedef is_mapped_reference_combinable > type;
BOOST_STATIC_CONSTANT(bool, value = true);
};
//------------------------------------------------------------------------------
template
struct is_mapped_reference_or_combinable{
typedef is_mapped_reference_or_combinable type;
BOOST_STATIC_CONSTANT(bool, value = is_mapped_reference_combinable::value);
};
template
struct is_mapped_reference_or_combinable >
{
typedef is_mapped_reference_or_combinable > type;
BOOST_STATIC_CONSTANT(bool, value = true);
};
//------------------------------------------------------------------------------
template
class mapped_reference
{
private:
mapped_reference& operator = (const mapped_reference&);
public:
typedef FirstT first_type;
typedef SecondT second_type;
typedef mapped_reference type;
typedef typename
mpl::if_,
second_type&,
const second_type&>::type second_reference_type;
typedef std::pair< first_type, second_type> std_pair_type;
typedef std::pair key_std_pair_type;
const first_type& first ;
second_reference_type second;
mapped_reference(const FirstT& fst, second_reference_type snd) : first(fst), second(snd){}
template
mapped_reference(const mapped_reference& source):
first(source.first), second(source.second){}
template
operator std::pair(){ return std::pair(first, second); }
template
typename enable_if, bool>::type
operator == (const Comparand& right)const
{ return first == right.first && second == right.second; }
template
typename enable_if, bool>::type
operator != (const Comparand& right)const
{ return !(*this == right); }
template
typename enable_if, bool>::type
operator < (const Comparand& right)const
{
return first < right.first
||(!(right.first < first) && second < right.second);
}
template
typename enable_if, bool>::type
operator > (const Comparand& right)const
{
return first > right.first
||(!(right.first > first) && second > right.second);
}
template
typename enable_if, bool>::type
operator <= (const Comparand& right)const
{
return !(*this > right);
}
template
typename enable_if, bool>::type
operator >= (const Comparand& right)const
{
return !(*this < right);
}
};
//------------------------------------------------------------------------------
template
inline typename enable_if, bool>::type
operator == ( const StdPairT& left,
const mapped_reference& right)
{
return right == left;
}
template
inline typename enable_if, bool>::type
operator != ( const StdPairT& left,
const mapped_reference& right)
{
return !(right == left);
}
//------------------------------------------------------------------------------
template
inline typename enable_if, bool>::type
operator < ( const StdPairT& left,
const mapped_reference& right)
{
return right > left;
}
//------------------------------------------------------------------------------
template
inline typename enable_if, bool>::type
operator > ( const StdPairT& left,
const mapped_reference& right)
{
return right < left;
}
//------------------------------------------------------------------------------
template
inline typename enable_if, bool>::type
operator <= ( const StdPairT& left,
const mapped_reference& right)
{
return !(right < left);
}
//------------------------------------------------------------------------------
template
inline typename enable_if, bool>::type
operator >= ( const StdPairT& left,
const mapped_reference& right)
{
return !(left < right);
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
template
inline mapped_reference make_mapped_reference(const FirstT& left, SecondT& right)
{ return mapped_reference(left, right); }
}} // namespace icl boost
#endif // BOOST_ICL_DETAIL_MAPPED_REFERENCE_HPP_JOFA_091108