Files
boost_algorithm/include/boost/algorithm/select.hpp
Jesse Williamson e9c9685fe9 Documentation updates and new Doxyfile; new unit test and minor fix;
moved minmax_macro; new example.


[SVN r52655]
2009-04-28 19:57:54 +00:00

55 lines
1.6 KiB
C++

/*
Copyright (c) Marshall Clow 2008.
Distributed under the Boost Software License, Version 1.0. (See accompanying
file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
Implemented by SGI in their STL implementation
This implemnetation is based on interprocess::detail::select1st by Ion Gaztanaga.
Revision history:
06 May 2008 mtc First version - as part of BoostCon 2008
*/
#ifndef BOOST_ALGORITHM_SELECT_HPP
#define BOOST_ALGORITHM_SELECT_HPP
/// \file select.hpp
/// \brief Choose the first or second element of a Pair.
/// \author Marshall Clow
namespace boost { namespace algorithm {
/// \struct select1st
/// \brief Unary function that returns the first element of a std::pair
///
/// \param p The pair.
/// \return p.first
///
///
template <class Pair>
struct select1st : public std::unary_function<Pair, typename Pair::first_type>
{
const typename Pair::first_type& operator()(const Pair& p) const { return p.first; }
typename Pair::first_type& operator()( Pair& p) const { return p.first; }
};
/// \struct select2nd
/// \brief Unary function that returns the first element of a std::pair
///
/// \param p The pair.
/// \return p.first
///
///
template <class Pair>
struct select2nd : public std::unary_function<Pair, typename Pair::second_type>
{
const typename Pair::second_type& operator()(const Pair& p) const { return p.second; }
typename Pair::second_type& operator()( Pair& p) const { return p.second; }
};
}} // namespace boost & algorithm
#endif // BOOST_ALGORITHM_SELECT_HPP