Simple Application Framework
1
|
00001 /* 00002 This file is part of Simple Application Framework (Saf) library. 00003 Copyright (C) 2010 - 2012 Ondrej Danek <ondrej.danek@gmail.com> 00004 00005 This library is free software: you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published 00007 by the Free Software Foundation, either version 3 of the License, or 00008 (at your option) any later version. 00009 00010 Saf is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with Simple Application Framework library. If not, 00017 see <http://www.gnu.org/licenses/>. 00018 */ 00019 00028 #ifndef SAF_ALGO_SELECTOR_H 00029 #define SAF_ALGO_SELECTOR_H 00030 00031 #include "Function.h" 00032 00033 namespace Saf 00034 { 00035 namespace Algo 00036 { 00040 namespace Selector 00041 { 00046 template <class PairClass> 00047 struct FirstMember 00048 : public UnaryFunction<PairClass, typename PairClass::FirstMemberType> 00049 { 00051 typename PairClass::FirstMemberType& operator()(PairClass& pr) const 00052 { 00053 return pr.m_first; 00054 } 00055 00057 const typename PairClass::FirstMemberType& operator()(const PairClass& pr) const 00058 { 00059 return pr.m_first; 00060 } 00061 }; 00062 00067 template <class PairClass> 00068 struct SecondMember 00069 : public UnaryFunction<PairClass, typename PairClass::SecondMemberType> 00070 { 00072 typename PairClass::SecondMemberType& operator()(PairClass& pr) const 00073 { 00074 return pr.m_second; 00075 } 00076 00078 const typename PairClass::SecondMemberType& operator()(const PairClass& pr) const 00079 { 00080 return pr.m_second; 00081 } 00082 }; 00083 00088 template <class TripletClass> 00089 struct ThirdMember 00090 : public UnaryFunction<TripletClass, typename TripletClass::ThirdMemberType> 00091 { 00093 typename TripletClass::ThirdMemberType& operator()(TripletClass& pr) const 00094 { 00095 return pr.m_third; 00096 } 00097 00099 const typename TripletClass::ThirdMemberType& operator()(const TripletClass& pr) const 00100 { 00101 return pr.m_third; 00102 } 00103 }; 00104 } 00105 } 00106 } 00107 00108 #endif