diff --git a/src/common/utilities.hh b/src/common/utilities.hh index 174af67..d6e7859 100644 --- a/src/common/utilities.hh +++ b/src/common/utilities.hh @@ -1,200 +1,198 @@ /** * file utilities.hh * * @author Till Junge * * @date 17 Nov 2017 * * @brief additions to the standard name space to anticipate C++17 features * * @section LICENCE * * Copyright © 2017 Till Junge * * µSpectre 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 3, or (at * your option) any later version. * * µSpectre 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 GNU Emacs; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef UTILITIES_H #define UTILITIES_H #include #include #ifdef NO_EXPERIMENTAL # if defined(__INTEL_COMPILER) //# pragma warning ( disable : 383 ) # elif defined (__clang__) // test clang to be sure that when we test for gnu it is only gnu # pragma clang diagnostic push -# pragma clang diagnostic ignored "Weffc++" +# pragma clang diagnostic ignored "-Weffc++" # elif (defined(__GNUC__) || defined(__GNUG__)) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Weffc++" # endif # include # if defined(__INTEL_COMPILER) //# pragma warning ( disable : 383 ) # elif defined (__clang__) // test clang to be sure that when we test for gnu it is only gnu # pragma clang diagnostic pop -# pragma clang diagnostic ignored "Weffc++" +# pragma clang diagnostic ignored "-Weffc++" # elif (defined(__GNUC__) || defined(__GNUG__)) # pragma GCC diagnostic pop # pragma GCC diagnostic ignored "-Weffc++" # endif #else # include #endif namespace std_replacement { namespace detail { template struct is_reference_wrapper : std::false_type {}; template struct is_reference_wrapper> : std::true_type {}; - template - constexpr bool is_reference_wrapper_v = is_reference_wrapper::value; template auto INVOKE(T Base::*pmf, Derived&& ref, Args&&... args) noexcept(noexcept((std::forward(ref).*pmf)(std::forward(args)...))) -> std::enable_if_t::value && std::is_base_of>::value, decltype((std::forward(ref).*pmf)(std::forward(args)...))> { return (std::forward(ref).*pmf)(std::forward(args)...); } template auto INVOKE(T Base::*pmf, RefWrap&& ref, Args&&... args) noexcept(noexcept((ref.get().*pmf)(std::forward(args)...))) -> std::enable_if_t::value && - is_reference_wrapper_v>, + is_reference_wrapper>::value, decltype((ref.get().*pmf)(std::forward(args)...))> { return (ref.get().*pmf)(std::forward(args)...); } template auto INVOKE(T Base::*pmf, Pointer&& ptr, Args&&... args) noexcept(noexcept(((*std::forward(ptr)).*pmf)(std::forward(args)...))) -> std::enable_if_t::value && - !is_reference_wrapper_v> && + !is_reference_wrapper>::value && !std::is_base_of>::value, decltype(((*std::forward(ptr)).*pmf)(std::forward(args)...))> { return ((*std::forward(ptr)).*pmf)(std::forward(args)...); } template auto INVOKE(T Base::*pmd, Derived&& ref) noexcept(noexcept(std::forward(ref).*pmd)) -> std::enable_if_t::value && std::is_base_of>::value, decltype(std::forward(ref).*pmd)> { return std::forward(ref).*pmd; } template auto INVOKE(T Base::*pmd, RefWrap&& ref) noexcept(noexcept(ref.get().*pmd)) -> std::enable_if_t::value && - is_reference_wrapper_v>, + is_reference_wrapper>::value, decltype(ref.get().*pmd)> { return ref.get().*pmd; } template auto INVOKE(T Base::*pmd, Pointer&& ptr) noexcept(noexcept((*std::forward(ptr)).*pmd)) -> std::enable_if_t::value && - !is_reference_wrapper_v> && + !is_reference_wrapper>::value && !std::is_base_of>::value, decltype((*std::forward(ptr)).*pmd)> { return (*std::forward(ptr)).*pmd; } template auto INVOKE(F&& f, Args&&... args) noexcept(noexcept(std::forward(f)(std::forward(args)...))) -> std::enable_if_t>::value, decltype(std::forward(f)(std::forward(args)...))> { return std::forward(f)(std::forward(args)...); } } // namespace detail template< class F, class... ArgTypes > auto invoke(F&& f, ArgTypes&&... args) // exception specification for QoI noexcept(noexcept(detail::INVOKE(std::forward(f), std::forward(args)...))) -> decltype(detail::INVOKE(std::forward(f), std::forward(args)...)) { return detail::INVOKE(std::forward(f), std::forward(args)...); } namespace detail { template constexpr decltype(auto) apply_impl(F &&f, Tuple &&t, std::index_sequence) { return std_replacement::invoke(std::forward(f), std::get(std::forward(t))...); } } // namespace detail template constexpr decltype(auto) apply(F &&f, Tuple &&t) { return detail::apply_impl (std::forward(f), std::forward(t), std::make_index_sequence>::value>{}); } } //namespace std_replacement namespace muSpectre { using std_replacement::apply; template #ifdef NO_EXPERIMENTAL using optional = typename boost::optional; #else using optional = typename std::experimental::optional; #endif /* ---------------------------------------------------------------------- */ template auto asStdTuple(BoostTuple&& boostTuple, std::index_sequence) { return std::tuple>::type...> (boost::get(std::forward(boostTuple))...); } template auto asStdTuple(BoostTuple&& boostTuple) { return asStdTuple(std::forward(boostTuple), std::make_index_sequence>::value>()); } } // muSpectre #endif /* UTILITIES_H */ diff --git a/tests/tests.hh b/tests/tests.hh index 0666ccd..ddaaf82 100644 --- a/tests/tests.hh +++ b/tests/tests.hh @@ -1,63 +1,63 @@ /** * file tests.hh * * @author Till Junge * * @date 10 May 2017 * * @brief common defs for tests * * @section LICENCE * * Copyright © 2017 Till Junge * * µSpectre 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 3, or (at * your option) any later version. * * µSpectre 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 GNU Emacs; see the file COPYING. If not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ #include "common/common.hh" # if defined(__INTEL_COMPILER) //# pragma warning ( disable : 383 ) # elif defined (__clang__) // test clang to be sure that when we test for gnu it is only gnu # pragma clang diagnostic push -# pragma clang diagnostic ignored "Weffc++" +# pragma clang diagnostic ignored "-Weffc++" # elif (defined(__GNUC__) || defined(__GNUG__)) # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Weffc++" # endif #include #include # if defined(__INTEL_COMPILER) //# pragma warning ( disable : 383 ) # elif defined (__clang__) // test clang to be sure that when we test for gnu it is only gnu # pragma clang diagnostic pop -# pragma clang diagnostic ignored "Weffc++" +# pragma clang diagnostic ignored "-Weffc++" # elif (defined(__GNUC__) || defined(__GNUG__)) # pragma GCC diagnostic pop # pragma GCC diagnostic ignored "-Weffc++" # endif #ifndef TESTS_H #define TESTS_H namespace muSpectre { const Real tol = 1e-14*100; //it's in percent } // muSpectre #endif /* TESTS_H */