Loading...
Searching...
No Matches
pair_util.h
Go to the documentation of this file.
#ifndef _RHEOLEF_PAIR_UTIL_H
#define _RHEOLEF_PAIR_UTIL_H
// useful class-functions for scanning containers of std::pair<T1,T2>
#include <utility> // for std::pair
#include <functional> // for std::unary_function
#include <iostream> // for debug
namespace rheolef {
template <class T1, class T2>
struct get_first : std::unary_function<std::pair<T1,T2>, T1> {
T1 operator() (const std::pair<T1,T2>& x) const { return x.first; }
};
template <class T1, class T2>
struct get_second : std::unary_function<std::pair<T1,T2>, T2> {
T2 operator() (const std::pair<T1,T2>& x) const { return x.second; }
};
template<typename InputPairIterator, typename OutputPairIterator, typename UnaryOperation>
OutputPairIterator
pair_transform_second (
InputPairIterator first,
InputPairIterator last,
OutputPairIterator result,
UnaryOperation unary_op)
{
for (; first != last; ++first, ++result)
(*result).second = unary_op ((*first).second);
return result;
}
#ifndef TO_CLEAN
template <class T1, class T2>
std::ostream&
operator<< (std::ostream& out, const std::pair<T1,T2>& x)
{
return out << "pair("<<x.first<<","<<x.second<<")";
}
#endif // TO_CLEAN
} // namespace rheolef
#endif // _RHEOLEF_PAIR_UTIL_H
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::operator<<
std::ostream & operator<<(std::ostream &os, const catchmark &m)
Definition catchmark.h:99
rheolef::pair_transform_second
OutputPairIterator pair_transform_second(InputPairIterator first, InputPairIterator last, OutputPairIterator result, UnaryOperation unary_op)
Definition pair_util.h:41
rheolef::get_first
Definition pair_util.h:31
rheolef::get_first::operator()
T1 operator()(const std::pair< T1, T2 > &x) const
Definition pair_util.h:32
rheolef::get_second
Definition pair_util.h:35
rheolef::get_second::operator()
T2 operator()(const std::pair< T1, T2 > &x) const
Definition pair_util.h:36