Lumiera  0.pre.03
»edit your freedom«
maybe-compare.hpp
Go to the documentation of this file.
1 /*
2  MAYBE-COMPARE.hpp - guarded invocation of comparisons
3 
4  Copyright (C) Lumiera.org
5  2009, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
29 #ifndef LIB_META_MAYBE_COMPARE_H
30 #define LIB_META_MAYBE_COMPARE_H
31 
32 
33 
34 
35 namespace lib {
36 namespace meta{
37 
38 
43  template<typename X>
44  struct Comparator
45  {
46  static bool
47  equals (X const& x1, X const& x2)
48  {
49  return x1 == x2;
50  }
51  };
52 
53  /* == add specialisations here == */
54 
55 
56  template<typename X>
57  inline bool
58  equals_safeInvoke (X const& x1, X const& x2)
59  {
60  return Comparator<X>::equals(x1,x2);
61  }
62 
63 
64 }} // namespace lib::meta
65 #endif
Implementation namespace for support and library code.
Trait template for invoking equality comparison.