/* MAYBE-COMPARE.hpp - guarded invocation of comparisons Copyright (C) Lumiera.org 2009, Hermann Vosseler This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /** @file §§§ ** TODO §§§ */ #ifndef LIB_META_MAYBE_COMPARE_H #define LIB_META_MAYBE_COMPARE_H #include "lib/functor-util.hpp" #include namespace lib { namespace meta{ using std::function; /** * Trait template for invoking equality comparison. * This allows to treat some types specifically.... */ template struct Comparator { static bool equals (X const& x1, X const& x2) { return x1 == x2; } }; /** while the boost function implementation doesn't provide comparison, * we'll use our private hack, which at least detects equivalence * in \em some cases... */ template struct Comparator > { static bool equals (function const& f1, function const& f2) { return util::rawComparison(f1,f2); } }; template inline bool equals_safeInvoke (X const& x1, X const& x2) { return Comparator::equals(x1,x2); } }} // namespace lib::meta #endif