]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/hana/include/boost/hana/detail/first_unsatisfied_index.hpp
bump version to 12.2.2-pve1
[ceph.git] / ceph / src / boost / libs / hana / include / boost / hana / detail / first_unsatisfied_index.hpp
CommitLineData
7c673cae
FG
1/*!
2@file
3Defines `boost::hana::detail::first_unsatisfied_index`.
4
5@copyright Louis Dionne 2013-2016
6Distributed under the Boost Software License, Version 1.0.
7(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
8 */
9
10#ifndef BOOST_HANA_DETAIL_FIRST_UNSATISFIED_INDEX_HPP
11#define BOOST_HANA_DETAIL_FIRST_UNSATISFIED_INDEX_HPP
12
13#include <boost/hana/config.hpp>
14#include <boost/hana/integral_constant.hpp>
15#include <boost/hana/value.hpp>
16
17#include <utility>
18
19
20BOOST_HANA_NAMESPACE_BEGIN namespace detail {
21 template <bool, typename Pred, typename ...Xs>
22 struct find_tail_size;
23
24 template <typename Pred, typename X, typename ...Xs>
25 struct find_tail_size<true, Pred, X, Xs...> {
26 static constexpr int value = find_tail_size<
27 static_cast<bool>(hana::value<decltype(std::declval<Pred>()(std::declval<X>()))>()),
28 Pred, Xs...
29 >::value;
30 };
31
32 template <typename Pred>
33 struct find_tail_size<true, Pred> {
34 static constexpr int value = -1;
35 };
36
37 template <typename Pred, typename ...Xs>
38 struct find_tail_size<false, Pred, Xs...> {
39 static constexpr int value = sizeof...(Xs);
40 };
41
42 //! @ingroup group-details
43 //! Returns the index of the first element which does not satisfy `Pred`,
44 //! or `sizeof...(Xs)` if no such element exists.
45 template <typename Pred>
46 struct first_unsatisfied_index {
47 template <typename ...Xs>
48 constexpr auto operator()(Xs&& ...) const {
49 return hana::size_c<
50 sizeof...(Xs) - 1 - find_tail_size<true, Pred, Xs&&...>::value
51 >;
52 }
53 };
54} BOOST_HANA_NAMESPACE_END
55
56#endif // !BOOST_HANA_DETAIL_FIRST_UNSATISFIED_INDEX_HPP