diff options
Diffstat (limited to 'boost/hana/sum.hpp')
-rw-r--r-- | boost/hana/sum.hpp | 30 |
1 files changed, 14 insertions, 16 deletions
diff --git a/boost/hana/sum.hpp b/boost/hana/sum.hpp index 5c86dafdde..2b6f6b8219 100644 --- a/boost/hana/sum.hpp +++ b/boost/hana/sum.hpp @@ -23,28 +23,26 @@ Distributed under the Boost Software License, Version 1.0. BOOST_HANA_NAMESPACE_BEGIN + //! @cond template <typename M> - struct sum_t { + template <typename Xs> + constexpr decltype(auto) sum_t<M>::operator()(Xs&& xs) const { + using S = typename hana::tag_of<Xs>::type; + using Sum = BOOST_HANA_DISPATCH_IF(sum_impl<S>, + hana::Foldable<S>::value + ); + #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS static_assert(hana::Monoid<M>::value, "hana::sum<M> requires 'M' to be a Monoid"); - #endif - - template <typename Xs> - constexpr decltype(auto) operator()(Xs&& xs) const { - using S = typename hana::tag_of<Xs>::type; - using Sum = BOOST_HANA_DISPATCH_IF(sum_impl<S>, - hana::Foldable<S>::value - ); - #ifndef BOOST_HANA_CONFIG_DISABLE_CONCEPT_CHECKS - static_assert(hana::Foldable<S>::value, - "hana::sum<M>(xs) requires 'xs' to be Foldable"); - #endif + static_assert(hana::Foldable<S>::value, + "hana::sum<M>(xs) requires 'xs' to be Foldable"); + #endif - return Sum::template apply<M>(static_cast<Xs&&>(xs)); - } - }; + return Sum::template apply<M>(static_cast<Xs&&>(xs)); + } + //! @endcond template <typename T, bool condition> struct sum_impl<T, when<condition>> : default_ { |