All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends Macros Pages
less_pointees.hpp
Go to the documentation of this file.
1 //=======================================================================
2 // Copyright (c) 2013 Piotr Wygocki
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7 //=======================================================================
15 #ifndef PAAL_LESS_POINTEES_HPP
16 #define PAAL_LESS_POINTEES_HPP
17 namespace paal {
18 
19 // TODO add to boost
25 template <class Comparator> struct less_pointees_t {
27  less_pointees_t(Comparator compare) : m_compare(compare) {}
28 
30  template <typename OptionalPointee>
31  bool operator()(OptionalPointee const &x, OptionalPointee const &y) const {
32  return !y ? false : (!x ? true : m_compare(*x, *y));
33  }
34 
35  private:
36  Comparator m_compare;
37 };
38 
47 template <class Comparator>
49  return less_pointees_t<Comparator>(compare);
50 }
51 
52 }
53 #endif // PAAL_LESS_POINTEES_HPP
less_pointees_t(Comparator compare)
constructor
compare pointee using comparator
less_pointees_t< Comparator > make_less_pointees_t(Comparator compare)
make function for less_pointees_t
bool operator()(OptionalPointee const &x, OptionalPointee const &y) const
compare operator()