2
0
mirror of https://github.com/boostorg/hana.git synced 2026-02-22 03:22:21 +00:00

Detail: First argument to dependent_on is now a boolean

This commit is contained in:
Louis Dionne
2014-07-27 10:43:44 -04:00
parent 98189f9d4b
commit 02dfa4d012
3 changed files with 11 additions and 11 deletions

View File

@@ -11,11 +11,11 @@ Distributed under the Boost Software License, Version 1.0.
#define BOOST_HANA_DETAIL_DEPENDENT_ON_HPP
namespace boost { namespace hana { namespace detail {
template <typename, typename T>
struct dependent_on_impl { using type = T; };
template <bool dummy, typename T>
struct dependent_on { using type = T; };
template <typename Dummy, typename T>
using dependent_on = typename dependent_on_impl<Dummy, T>::type;
template <bool dummy, typename T>
using dependent_on_t = typename dependent_on<dummy, T>::type;
}}} // end namespace boost::hana::detail
#endif // !BOOST_HANA_DETAIL_DEPENDENT_ON_HPP

View File

@@ -103,7 +103,7 @@ namespace boost { namespace hana {
//! @snippet example/maybe/foldable.cpp main
template <typename ...Nothing>
struct Foldable::instance<Maybe, Nothing...>
: detail::dependent_on<char[sizeof...(Nothing) + 1], Foldable::mcd>
: detail::dependent_on_t<(bool)sizeof...(Nothing), Foldable::mcd>
{
template <typename F, typename S, typename M>
static constexpr auto foldr_impl(F f, S s, M m)

View File

@@ -136,19 +136,19 @@ namespace boost { namespace hana {
template <typename f>
struct metafunction_class {
// We need to delay the fetching of `f::apply` in case `f` is
// invalid because we want to stay SFINAE friendly.
// We use `dependent_on` to delay the fetching of `f::apply` in
// case `f` is invalid because we want to stay SFINAE friendly.
template <typename ...xs>
using apply = typename detail::dependent_on<
char[static_cast<bool>(sizeof...(xs)) + 1], f
>::template apply<xs...>;
(bool)sizeof...(xs), f
>::type::template apply<xs...>;
template <typename ...xs>
constexpr auto operator()(xs...) const -> decltype(
type<
typename detail::dependent_on<
char[static_cast<bool>(sizeof...(xs)) + 1], f
>::template apply<typename xs::type...>::type
(bool)sizeof...(xs), f
>::type::template apply<typename xs::type...>::type
>
) { return {}; }
};