?????????? ????????? - ??????????????? - /home/agenciai/public_html/cd38d8/fwd.zip
???????
PK �|!\#tX X repeat.hppnu �[��� /*! @file Forward declares `boost::hana::repeat`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_REPEAT_HPP #define BOOST_HANA_FWD_REPEAT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Invokes a nullary function `n` times. //! @ingroup group-IntegralConstant //! //! Given an `IntegralConstant` `n` and a nullary function `f`, //! `repeat(n, f)` will call `f` `n` times. In particular, any //! decent compiler should expand `repeat(n, f)` to //! @code //! f(); f(); ... f(); // n times total //! @endcode //! //! //! @param n //! An `IntegralConstant` holding a non-negative value representing //! the number of times `f` should be repeatedly invoked. //! //! @param f //! A function to repeatedly invoke `n` times. `f` is allowed to have //! side effects. //! //! //! Example //! ------- //! @include example/repeat.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto repeat = [](auto const& n, auto&& f) -> void { f(); f(); ... f(); // n times total }; #else template <typename N, typename = void> struct repeat_impl : repeat_impl<N, when<true>> { }; struct repeat_t { template <typename N, typename F> constexpr void operator()(N const& n, F&& f) const; }; constexpr repeat_t repeat{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_REPEAT_HPP PK �|!\VTn�b b count_if.hppnu �[��� /*! @file Forward declares `boost::hana::count_if`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_COUNT_IF_HPP #define BOOST_HANA_FWD_COUNT_IF_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Return the number of elements in the structure for which the //! `predicate` is satisfied. //! @ingroup group-Foldable //! //! Specifically, returns an object of an unsigned integral type, or //! a `Constant` holding such an object, which represents the number //! of elements in the structure satisfying the given `predicate`. //! //! //! @param xs //! The structure whose elements are counted. //! //! @param predicate //! A function called as `predicate(x)`, where `x` is an element of the //! structure, and returning a `Logical` representing whether `x` should //! be counted. //! //! //! Example //! ------- //! @include example/count_if.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto count_if = [](auto&& xs, auto&& predicate) { return tag-dispatched; }; #else template <typename T, typename = void> struct count_if_impl : count_if_impl<T, when<true>> { }; struct count_if_t { template <typename Xs, typename Pred> constexpr auto operator()(Xs&& xs, Pred&& pred) const; }; constexpr count_if_t count_if{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_COUNT_IF_HPP PK �|!\+� group.hppnu �[��� /*! @file Forward declares `boost::hana::group`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_GROUP_HPP #define BOOST_HANA_FWD_GROUP_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> #include <boost/hana/detail/nested_by_fwd.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Group adjacent elements of a sequence that all respect a binary //! predicate, by default equality. //! @ingroup group-Sequence //! //! Given a _finite_ Sequence and an optional predicate (by default //! `equal`), `group` returns a sequence of subsequences representing //! groups of adjacent elements that are "equal" with respect to the //! predicate. In other words, the groups are such that the predicate is //! satisfied when it is applied to any two adjacent elements in that //! group. The sequence returned by `group` is such that the concatenation //! of its elements is equal to the original sequence, which is equivalent //! to saying that the order of the elements is not changed. //! //! If no predicate is provided, adjacent elements in the sequence must //! all be compile-time `Comparable`. //! //! //! Signature //! --------- //! Given a Sequence `s` with tag `S(T)`, an `IntegralConstant` `Bool` //! holding a value of type `bool`, and a predicate //! \f$ pred : T \times T \to Bool \f$, `group` has the following //! signatures. For the variant with a provided predicate, //! \f[ //! \mathtt{group} : S(T) \times (T \times T \to Bool) \to S(S(T)) //! \f] //! //! for the variant without a custom predicate, `T` is required to be //! Comparable. The signature is then //! \f[ //! \mathtt{group} : S(T) \to S(S(T)) //! \f] //! //! @param xs //! The sequence to split into groups. //! //! @param predicate //! A binary function called as `predicate(x, y)`, where `x` and `y` are //! _adjacent_ elements in the sequence, whether both elements should be //! in the same group (subsequence) of the result. In the current version //! of the library, the result returned by `predicate` must be an //! `IntegralConstant` holding a value of a type convertible to `bool`. //! Also, `predicate` has to define an equivalence relation as defined by //! the `Comparable` concept. When this predicate is not provided, it //! defaults to `equal`, which requires the comparison of any two adjacent //! elements in the sequence to return a boolean `IntegralConstant`. //! //! //! Syntactic sugar (`group.by`) //! ---------------------------- //! `group` can be called in a third way, which provides a nice syntax //! especially when working with the `comparing` combinator: //! @code //! group.by(predicate, xs) == group(xs, predicate) //! group.by(predicate) == group(-, predicate) //! @endcode //! //! where `group(-, predicate)` denotes the partial application of //! `group` to `predicate`. //! //! //! Example //! ------- //! @include example/group.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto group = [](auto&& xs[, auto&& predicate]) { return tag-dispatched; }; #else template <typename S, typename = void> struct group_impl : group_impl<S, when<true>> { }; struct group_t : detail::nested_by<group_t> { template <typename Xs> constexpr auto operator()(Xs&& xs) const; template <typename Xs, typename Predicate> constexpr auto operator()(Xs&& xs, Predicate&& pred) const; }; constexpr group_t group{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_GROUP_HPP PK �|!\��cy y front.hppnu �[��� /*! @file Forward declares `boost::hana::front`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FRONT_HPP #define BOOST_HANA_FWD_FRONT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns the first element of a non-empty iterable. //! @ingroup group-Iterable //! //! Given a non-empty Iterable `xs` with a linearization of `[x1, ..., xN]`, //! `front(xs)` is equal to `x1`. If `xs` is empty, it is an error to //! use this function. Equivalently, `front(xs)` must be equivalent to //! `at_c<0>(xs)`, and that regardless of the value category of `xs` //! (`front` must respect the reference semantics of `at`). //! //! //! Example //! ------- //! @include example/front.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto front = [](auto&& xs) -> decltype(auto) { return tag-dispatched; }; #else template <typename It, typename = void> struct front_impl : front_impl<It, when<true>> { }; struct front_t { template <typename Xs> constexpr decltype(auto) operator()(Xs&& xs) const; }; constexpr front_t front{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FRONT_HPP PK �|!\�'BF� � scan_right.hppnu �[��� /*! @file Forward declares `boost::hana::scan_right`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_SCAN_RIGHT_HPP #define BOOST_HANA_FWD_SCAN_RIGHT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Fold a Sequence to the right and return a list containing the //! successive reduction states. //! @ingroup group-Sequence //! //! Like `fold_right`, `scan_right` reduces a sequence to a single value //! using a binary operation. However, unlike `fold_right`, it builds up //! a sequence of the intermediary results computed along the way and //! returns that instead of only the final reduction state. Like //! `fold_right`, `scan_right` can be used with or without an initial //! reduction state. //! //! When the sequence is empty, two things may arise. If an initial state //! was provided, a singleton list containing that state is returned. //! Otherwise, if no initial state was provided, an empty list is //! returned. In particular, unlike for `fold_right`, using `scan_right` //! on an empty sequence without an initial state is not an error. //! //! More specifically, `scan_right([x1, ..., xn], state, f)` is a sequence //! whose `i`th element is equivalent to `fold_right([x1, ..., xi], state, f)`. //! The no-state variant is handled in an analogous way. For illustration, //! consider this right fold on a short sequence: //! @code //! fold_right([x1, x2, x3], state, f) == f(x1, f(x2, f(x3, state))) //! @endcode //! //! The analogous sequence generated with `scan_right` will be //! @code //! scan_right([x1, x2, x3], state, f) == [ //! f(x1, f(x2, f(x3, state))), //! f(x2, f(x3, state)), //! f(x3, state), //! state //! ] //! @endcode //! //! Similarly, consider this right fold (without an initial state) on //! a short sequence: //! @code //! fold_right([x1, x2, x3, x4], f) == f(x1, f(x2, f(x3, x4))) //! @endcode //! //! The analogous sequence generated with `scan_right` will be //! @code //! scan_right([x1, x2, x3, x4], f) == [ //! f(x1, f(x2, f(x3, x4))), //! f(x2, f(x3, x4)), //! f(x3, x4), //! x4 //! ] //! @endcode //! //! @param xs //! The sequence to scan from the right. //! //! @param state //! The (optional) initial reduction state. //! //! @param f //! A binary function called as `f(x, state)`, where `state` is the //! result accumulated so far and `x` is an element in the sequence. //! When no initial state is provided, `f` is called as `f(x1, x2)`, //! where `x1` and `x2` are elements of the sequence. //! //! //! Example //! ------- //! @include example/scan_right.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto scan_right = [](auto&& xs[, auto&& state], auto const& f) { return tag-dispatched; }; #else template <typename S, typename = void> struct scan_right_impl : scan_right_impl<S, when<true>> { }; struct scan_right_t { template <typename Xs, typename State, typename F> constexpr auto operator()(Xs&& xs, State&& state, F const& f) const; template <typename Xs, typename F> constexpr auto operator()(Xs&& xs, F const& f) const; }; constexpr scan_right_t scan_right{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_SCAN_RIGHT_HPP PK �|!\C�#?2 2 adapt_struct.hppnu �[��� /*! @file Documents the `BOOST_HANA_ADAPT_STRUCT` macro. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ADAPT_STRUCT_HPP #define BOOST_HANA_FWD_ADAPT_STRUCT_HPP #include <boost/hana/config.hpp> BOOST_HANA_NAMESPACE_BEGIN // Note: // The weird definition as a variable seems to exploit a glitch in Doxygen // which makes the macro appear in the related objects of Struct (as we // want it to). //! Defines a model of `Struct` with the given members. //! @ingroup group-Struct //! //! Using this macro at _global scope_ will define a model of the `Struct` //! concept for the given type. This can be used to easily adapt existing //! user-defined types in a ad-hoc manner. Unlike the //! `BOOST_HANA_DEFINE_STRUCT` macro, this macro does not //! require the types of the members to be specified. //! //! @note //! This macro only works if the tag of the user-defined type `T` is `T` //! itself. This is the case unless you specifically asked for something //! different; see `tag_of`'s documentation. //! //! //! Example //! ------- //! @include example/adapt_struct.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED auto BOOST_HANA_ADAPT_STRUCT(...) = ; #define BOOST_HANA_ADAPT_STRUCT(Name, ...) see documentation #else // defined in <boost/hana/adapt_struct.hpp> #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ADAPT_STRUCT_HPP PK �|!\�:, , fuse.hppnu �[��� /*! @file Forward declares `boost::hana::fuse`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FUSE_HPP #define BOOST_HANA_FWD_FUSE_HPP #include <boost/hana/config.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Transform a function taking multiple arguments into a function that //! can be called with a compile-time `Foldable`. //! @ingroup group-Foldable //! //! //! This function is provided for convenience as a different way of //! calling `unpack`. Specifically, `fuse(f)` is a function such that //! @code //! fuse(f)(foldable) == unpack(foldable, f) //! == f(x...) //! @endcode //! where `x...` are the elements in the foldable. This function is //! useful when one wants to create a function that accepts a foldable //! which is not known yet. //! //! @note //! This function is not tag-dispatched; customize `unpack` instead. //! //! //! Example //! ------- //! @include example/fuse.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto fuse = [](auto&& f) { return [perfect-capture](auto&& xs) -> decltype(auto) { return unpack(forwarded(xs), forwarded(f)); }; }; #else struct fuse_t { template <typename F> constexpr auto operator()(F&& f) const; }; constexpr fuse_t fuse{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FUSE_HPP PK �|!\,f5ۥ � any_of.hppnu �[��� /*! @file Forward declares `boost::hana::any_of`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ANY_OF_HPP #define BOOST_HANA_FWD_ANY_OF_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns whether any key of the structure satisfies the `predicate`. //! @ingroup group-Searchable //! //! If the structure is not finite, `predicate` has to be satisfied //! after looking at a finite number of keys for this method to finish. //! //! //! @param xs //! The structure to search. //! //! @param predicate //! A function called as `predicate(k)`, where `k` is a key of the //! structure, and returning a `Logical`. //! //! //! Example //! ------- //! @include example/any_of.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto any_of = [](auto&& xs, auto&& predicate) { return tag-dispatched; }; #else template <typename S, typename = void> struct any_of_impl : any_of_impl<S, when<true>> { }; struct any_of_t { template <typename Xs, typename Pred> constexpr auto operator()(Xs&& xs, Pred&& pred) const; }; constexpr any_of_t any_of{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ANY_OF_HPP PK �|!\"��2� � lazy.hppnu �[��� /*! @file Forward declares `boost::hana::lazy`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_LAZY_HPP #define BOOST_HANA_FWD_LAZY_HPP #include <boost/hana/config.hpp> #include <boost/hana/fwd/core/make.hpp> BOOST_HANA_NAMESPACE_BEGIN //! @ingroup group-datatypes //! `hana::lazy` implements superficial laziness via a monadic interface. //! //! It is important to understand that the laziness implemented by `lazy` //! is only superficial; only function applications made inside the `lazy` //! monad can be made lazy, not all their subexpressions. //! //! //! @note //! The actual representation of `hana::lazy` is completely //! implementation-defined. Lazy values may only be created through //! `hana::make_lazy`, and they can be stored in variables using //! `auto`, but any other assumption about the representation of //! `hana::lazy<...>` should be avoided. In particular, one should //! not rely on the fact that `hana::lazy<...>` can be pattern-matched //! on, because it may be a dependent type. //! //! //! Modeled concepts //! ---------------- //! 1. `Functor`\n //! Applying a function over a lazy value with `transform` returns the //! result of applying the function, as a lazy value. //! @include example/lazy/functor.cpp //! //! 2. `Applicative`\n //! A normal value can be lifted into a lazy value by using `lift<lazy_tag>`. //! A lazy function can be lazily applied to a lazy value by using `ap`. //! //! 3. `Monad`\n //! The `lazy` monad allows combining lazy computations into larger //! lazy computations. Note that the `|` operator can be used in place //! of the `chain` function. //! @include example/lazy/monad.cpp //! //! 4. `Comonad`\n //! The `lazy` comonad allows evaluating a lazy computation to get its //! result and lazily applying functions taking lazy inputs to lazy //! values. This [blog post][1] goes into more details about lazy //! evaluation and comonads. //! @include example/lazy/comonad.cpp //! //! //! @note //! `hana::lazy` only models a few concepts because providing more //! functionality would require evaluating the lazy values in most cases. //! Since this raises some issues such as side effects and memoization, //! the interface is kept minimal. //! //! //! [1]: http://ldionne.com/2015/03/16/laziness-as-a-comonad #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename implementation_defined> struct lazy { //! Equivalent to `hana::chain`. template <typename ...T, typename F> friend constexpr auto operator|(lazy<T...>, F); }; #else // We do not _actually_ define the lazy<...> type. Per the documentation, // users can't rely on it being anything, and so they should never use // it explicitly. The implementation in <boost/hana/lazy.hpp> is much // simpler if we use different types for lazy calls and lazy values. #endif //! Tag representing `hana::lazy`. //! @relates hana::lazy struct lazy_tag { }; //! Lifts a normal value to a lazy one. //! @relates hana::lazy //! //! `make<lazy_tag>` can be used to lift a normal value or a function call //! into a lazy expression. Precisely, `make<lazy_tag>(x)` is a lazy value //! equal to `x`, and `make<lazy_tag>(f)(x1, ..., xN)` is a lazy function //! call that is equal to `f(x1, ..., xN)` when it is `eval`uated. //! //! @note //! It is interesting to note that `make<lazy_tag>(f)(x1, ..., xN)` is //! equivalent to //! @code //! ap(make<lazy_tag>(f), lift<lazy_tag>(x1), ..., lift<lazy_tag>(xN)) //! @endcode //! which in turn is equivalent to `make<lazy_tag>(f(x1, ..., xN))`, except //! for the fact that the inner call to `f` is evaluated lazily. //! //! //! Example //! ------- //! @include example/lazy/make.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <> constexpr auto make<lazy_tag> = [](auto&& x) { return lazy<implementation_defined>{forwarded(x)}; }; #endif //! Alias to `make<lazy_tag>`; provided for convenience. //! @relates hana::lazy //! //! Example //! ------- //! @include example/lazy/make.cpp constexpr auto make_lazy = make<lazy_tag>; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_LAZY_HPP PK �|!\Ud;k k core.hppnu �[��� /*! @file Forward declares the @ref group-core module. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_CORE_HPP #define BOOST_HANA_FWD_CORE_HPP #include <boost/hana/fwd/core/common.hpp> #include <boost/hana/fwd/core/to.hpp> #include <boost/hana/fwd/core/default.hpp> #include <boost/hana/fwd/core/is_a.hpp> #include <boost/hana/fwd/core/make.hpp> #include <boost/hana/fwd/core/tag_of.hpp> #include <boost/hana/fwd/core/when.hpp> #endif // !BOOST_HANA_FWD_CORE_HPP PK �|!\;���� � unfold_left.hppnu �[��� /*! @file Forward declares `boost::hana::unfold_left`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_UNFOLD_LEFT_HPP #define BOOST_HANA_FWD_UNFOLD_LEFT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Dual operation to `fold_left` for sequences. //! @ingroup group-Sequence //! //! While `fold_left` reduces a structure to a summary value from the left, //! `unfold_left` builds a sequence from a seed value and a function, //! starting from the left. //! //! //! Signature //! --------- //! Given a `Sequence` `S`, an initial value `state` of tag `I`, an //! arbitrary Product `P` and a function \f$ f : I \to P(I, T) \f$, //! `unfold_left<S>` has the following signature: //! \f[ //! \mathtt{unfold\_left}_S : I \times (I \to P(I, T)) \to S(T) //! \f] //! //! @tparam S //! The tag of the sequence to build up. //! //! @param state //! An initial value to build the sequence from. //! //! @param f //! A function called as `f(state)`, where `state` is an initial value, //! and returning //! 1. `nothing` if it is done producing the sequence. //! 2. otherwise, `just(make<P>(state, x))`, where `state` is the new //! initial value used in the next call to `f`, `x` is an element to //! be appended to the resulting sequence, and `P` is an arbitrary //! `Product`. //! //! //! Fun fact //! --------- //! In some cases, `unfold_left` can undo a `fold_left` operation: //! @code //! unfold_left<S>(fold_left(xs, state, f), g) == xs //! @endcode //! //! if the following holds //! @code //! g(f(x, y)) == just(make_pair(x, y)) //! g(state) == nothing //! @endcode //! //! //! Example //! ------- //! @include example/unfold_left.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename S> constexpr auto unfold_left = [](auto&& state, auto&& f) { return tag-dispatched; }; #else template <typename S, typename = void> struct unfold_left_impl : unfold_left_impl<S, when<true>> { }; template <typename S> struct unfold_left_t; template <typename S> constexpr unfold_left_t<S> unfold_left{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_UNFOLD_LEFT_HPP PK �|!\�pd\ \ one.hppnu �[��� /*! @file Forward declares `boost::hana::one`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ONE_HPP #define BOOST_HANA_FWD_ONE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Identity of the `Ring` multiplication. //! @ingroup group-Ring //! //! @tparam R //! The tag (must be a model of `Ring`) of the returned identity. //! //! //! Example //! ------- //! @include example/one.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename R> constexpr auto one = []() -> decltype(auto) { return tag-dispatched; }; #else template <typename R, typename = void> struct one_impl : one_impl<R, when<true>> { }; template <typename R> struct one_t { constexpr decltype(auto) operator()() const; }; template <typename R> constexpr one_t<R> one{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ONE_HPP PK �|!\3ooϰ � monadic_fold_left.hppnu �[��� /*! @file Forward declares `boost::hana::monadic_fold_left`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_MONADIC_FOLD_LEFT_HPP #define BOOST_HANA_FWD_MONADIC_FOLD_LEFT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Monadic left-fold of a structure with a binary operation and an //! optional initial reduction state. //! @ingroup group-Foldable //! //! @note //! This assumes the reader to be accustomed to non-monadic left-folds as //! explained by `hana::fold_left`, and to have read the [primer] //! (@ref monadic-folds) on monadic folds. //! //! `monadic_fold_left<M>` is a left-associative monadic fold. Given a //! `Foldable` with linearization `[x1, ..., xn]`, a function `f` and an //! optional initial state, `monadic_fold_left<M>` applies `f` as follows: //! @code //! // with state //! ((((f(state, x1) | f(-, x2)) | f(-, x3)) | ...) | f(-, xn)) //! //! // without state //! ((((f(x1, x2) | f(-, x3)) | f(-, x4)) | ...) | f(-, xn)) //! @endcode //! //! where `f(-, xk)` denotes the partial application of `f` to `xk`, and //! `|` is just the operator version of the monadic `chain`. //! //! When the structure is empty, one of two things may happen. If an //! initial state was provided, it is lifted to the given Monad and //! returned as-is. Otherwise, if the no-state version of the function //! was used, an error is triggered. When the stucture contains a single //! element and the no-state version of the function was used, that //! single element is lifted into the given Monad and returned as is. //! //! //! Signature //! --------- //! Given a `Monad` `M`, a `Foldable` `F`, an initial state of tag `S`, //! and a function @f$ f : S \times T \to M(S) @f$, the signatures of //! `monadic_fold_left<M>` are //! \f[ //! \mathtt{monadic\_fold\_left}_M : //! F(T) \times S \times (S \times T \to M(S)) \to M(S) //! \f] //! //! for the version with an initial state, and //! \f[ //! \mathtt{monadic\_fold\_left}_M : //! F(T) \times (T \times T \to M(T)) \to M(T) //! \f] //! //! for the version without an initial state. //! //! @tparam M //! The Monad representing the monadic context in which the fold happens. //! The return type of `f` must be in that Monad. //! //! @param xs //! The structure to fold. //! //! @param state //! The initial value used for folding. If the structure is empty, this //! value is lifted in to the `M` Monad and then returned as-is. //! //! @param f //! A binary function called as `f(state, x)`, where `state` is the result //! accumulated so far and `x` is an element in the structure. The //! function must return its result inside the `M` Monad. //! //! //! Example //! ------- //! @include example/monadic_fold_left.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename M> constexpr auto monadic_fold_left = [](auto&& xs[, auto&& state], auto&& f) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename = void> struct monadic_fold_left_impl : monadic_fold_left_impl<T, when<true>> { }; template <typename M> struct monadic_fold_left_t { template <typename Xs, typename State, typename F> constexpr decltype(auto) operator()(Xs&& xs, State&& state, F&& f) const; template <typename Xs, typename F> constexpr decltype(auto) operator()(Xs&& xs, F&& f) const; }; template <typename M> constexpr monadic_fold_left_t<M> monadic_fold_left{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MONADIC_FOLD_LEFT_HPP PK �|!\?��� � zip_with.hppnu �[��� /*! @file Forward declares `boost::hana::zip_with`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ZIP_WITH_HPP #define BOOST_HANA_FWD_ZIP_WITH_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Zip one sequence or more with a given function. //! @ingroup group-Sequence //! //! Given a `n`-ary function `f` and `n` sequences `s1, ..., sn`, //! `zip_with` produces a sequence whose `i`-th element is //! `f(s1[i], ..., sn[i])`, where `sk[i]` denotes the `i`-th element of //! the `k`-th sequence. In other words, `zip_with` produces a sequence //! of the form //! @code //! [ //! f(s1[0], ..., sn[0]), //! f(s1[1], ..., sn[1]), //! ... //! f(s1[M], ..., sn[M]) //! ] //! @endcode //! where `M` is the length of the sequences, which are all assumed to //! have the same length. Assuming the sequences to all have the same size //! allows the library to perform some optimizations. To zip sequences //! that may have different lengths, `zip_shortest_with` should be used //! instead. Also note that it is an error to provide no sequence at all, //! i.e. `zip_with` expects at least one sequence. //! //! //! Example //! ------- //! @include example/zip_with.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto zip_with = [](auto&& f, auto&& x1, ..., auto&& xn) { return tag-dispatched; }; #else template <typename S, typename = void> struct zip_with_impl : zip_with_impl<S, when<true>> { }; struct zip_with_t { template <typename F, typename Xs, typename ...Ys> constexpr auto operator()(F&& f, Xs&& xs, Ys&& ...ys) const; }; constexpr zip_with_t zip_with{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ZIP_WITH_HPP PK �|!\?�h� � append.hppnu �[��� /*! @file Forward declares `boost::hana::append`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_APPEND_HPP #define BOOST_HANA_FWD_APPEND_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Append an element to a monadic structure. //! @ingroup group-MonadPlus //! //! Given an element `x` and a monadic structure `xs`, `append` returns a //! new monadic structure which is the result of lifting `x` into the //! monadic structure and then combining that (to the right) with `xs`. //! In other words, //! @code //! append(xs, x) == concat(xs, lift<Xs>(x)) //! @endcode //! where `Xs` is the tag of `xs`. For sequences, this has the intuitive //! behavior of simply appending an element to the end of the sequence, //! hence the name. //! //! > #### Rationale for not calling this `push_back` //! > See the rationale for using `prepend` instead of `push_front`. //! //! //! Signature //! --------- //! Given a MonadPlus `M`, the signature is //! @f$ \mathtt{append} : M(T) \times T \to M(T) @f$. //! //! @param xs //! A monadic structure that will be combined to the left of the element. //! //! @param x //! An element to combine to the right of the monadic structure. //! //! //! Example //! ------- //! @include example/append.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto append = [](auto&& xs, auto&& x) { return tag-dispatched; }; #else template <typename M, typename = void> struct append_impl : append_impl<M, when<true>> { }; struct append_t { template <typename Xs, typename X> constexpr auto operator()(Xs&& xs, X&& x) const; }; constexpr append_t append{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_APPEND_HPP PK �|!\!^m�� � flatten.hppnu �[��� /*! @file Forward declares `boost::hana::flatten`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FLATTEN_HPP #define BOOST_HANA_FWD_FLATTEN_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Collapse two levels of monadic structure into a single level. //! @ingroup group-Monad //! //! Given a monadic value wrapped into two levels of monad, `flatten` //! removes one such level. An implementation of `flatten` must satisfy //! @code //! flatten(xs) == chain(xs, id) //! @endcode //! //! For `Sequence`s, this simply takes a `Sequence` of `Sequence`s, and //! returns a (non-recursively) flattened `Sequence`. //! //! //! Signature //! --------- //! For a `Monad` `M`, the signature of `flatten` is //! @f$ //! \mathtt{flatten} : M(M(T)) \to M(T) //! @f$ //! //! @param xs //! A value with two levels of monadic structure, which should be //! collapsed into a single level of structure. //! //! //! Example //! ------- //! @include example/flatten.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto flatten = [](auto&& xs) { return tag-dispatched; }; #else template <typename M, typename = void> struct flatten_impl : flatten_impl<M, when<true>> { }; struct flatten_t { template <typename Xs> constexpr auto operator()(Xs&& xs) const; }; constexpr flatten_t flatten{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FLATTEN_HPP PK �|!\� >� � fill.hppnu �[��� /*! @file Forward declares `boost::hana::fill`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FILL_HPP #define BOOST_HANA_FWD_FILL_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Replace all the elements of a structure with a fixed value. //! @ingroup group-Functor //! //! //! Signature //! --------- //! Given `F` a Functor, the signature is //! \f$ //! \mathtt{fill} : F(T) \times U \to F(U) //! \f$ //! //! @param xs //! The structure to fill with a `value`. //! //! @param value //! A value by which every element `x` of the structure is replaced, //! unconditionally. //! //! //! Example //! ------- //! @include example/fill.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto fill = [](auto&& xs, auto&& value) { return tag-dispatched; }; #else template <typename Xs, typename = void> struct fill_impl : fill_impl<Xs, when<true>> { }; struct fill_t { template <typename Xs, typename Value> constexpr auto operator()(Xs&& xs, Value&& value) const; }; constexpr fill_t fill{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FILL_HPP PK �|!\���h h intersection.hppnu �[��� /*! @file Forward declares `boost::hana::intersection`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_INTERSECTION_HPP #define BOOST_HANA_FWD_INTERSECTION_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN // Note: This function is documented per datatype/concept only. //! @cond template <typename S, typename = void> struct intersection_impl : intersection_impl<S, when<true>> { }; //! @endcond struct intersection_t { template <typename Xs, typename Ys> constexpr auto operator()(Xs&&, Ys&&) const; }; constexpr intersection_t intersection{}; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_INTERSECTION_HPP PK �|!\ empty.hppnu �[��� /*! @file Forward declares `boost::hana::empty`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_EMPTY_HPP #define BOOST_HANA_FWD_EMPTY_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Identity of the monadic combination `concat`. //! @ingroup group-MonadPlus //! //! Signature //! --------- //! Given a MonadPlus `M`, the signature is //! @f$ \mathtt{empty}_M : \emptyset \to M(T) @f$. //! //! @tparam M //! The tag of the monadic structure to return. This must be //! a model of the MonadPlus concept. //! //! //! Example //! ------- //! @include example/empty.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename M> constexpr auto empty = []() { return tag-dispatched; }; #else template <typename M, typename = void> struct empty_impl : empty_impl<M, when<true>> { }; template <typename M> struct empty_t { constexpr auto operator()() const; }; template <typename M> constexpr empty_t<M> empty{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_EMPTY_HPP PK �|!\�5�� � min.hppnu �[��� /*! @file Forward declares `boost::hana::min`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_MIN_HPP #define BOOST_HANA_FWD_MIN_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns the smallest of its arguments according to the `less` ordering. //! @ingroup group-Orderable //! //! //! @todo //! We can't specify the signature right now, because the tag of the //! returned object depends on whether `x < y` or not. If we wanted to be //! mathematically correct, we should probably ask that `if_(cond, x, y)` //! returns a common data type of `x` and `y`, and then the behavior //! of `min` would follow naturally. However, I'm unsure whether this //! is desirable because that's a big requirement. //! //! //! Example //! ------- //! @include example/min.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto min = [](auto&& x, auto&& y) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename U, typename = void> struct min_impl : min_impl<T, U, when<true>> { }; struct min_t { template <typename X, typename Y> constexpr decltype(auto) operator()(X&& x, Y&& y) const; }; constexpr min_t min{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MIN_HPP PK �|!\��qӷ � integral_constant.hppnu �[��� /*! @file Forward declares `boost::hana::integral_constant`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_INTEGRAL_CONSTANT_HPP #define BOOST_HANA_FWD_INTEGRAL_CONSTANT_HPP #include <boost/hana/config.hpp> #include <boost/hana/detail/integral_constant.hpp> #include <cstddef> BOOST_HANA_NAMESPACE_BEGIN //! Creates an `integral_constant` holding the given compile-time value. //! @relates hana::integral_constant //! //! Specifically, `integral_c<T, v>` is a `hana::integral_constant` //! holding the compile-time value `v` of an integral type `T`. //! //! //! @tparam T //! The type of the value to hold in the `integral_constant`. //! It must be an integral type. //! //! @tparam v //! The integral value to hold in the `integral_constant`. //! //! //! Example //! ------- //! @snippet example/integral_constant.cpp integral_c template <typename T, T v> constexpr integral_constant<T, v> integral_c{}; //! @relates hana::integral_constant template <bool b> using bool_ = integral_constant<bool, b>; //! @relates hana::integral_constant template <bool b> constexpr bool_<b> bool_c{}; //! @relates hana::integral_constant using true_ = bool_<true>; //! @relates hana::integral_constant constexpr auto true_c = bool_c<true>; //! @relates hana::integral_constant using false_ = bool_<false>; //! @relates hana::integral_constant constexpr auto false_c = bool_c<false>; //! @relates hana::integral_constant template <char c> using char_ = integral_constant<char, c>; //! @relates hana::integral_constant template <char c> constexpr char_<c> char_c{}; //! @relates hana::integral_constant template <short i> using short_ = integral_constant<short, i>; //! @relates hana::integral_constant template <short i> constexpr short_<i> short_c{}; //! @relates hana::integral_constant template <unsigned short i> using ushort_ = integral_constant<unsigned short, i>; //! @relates hana::integral_constant template <unsigned short i> constexpr ushort_<i> ushort_c{}; //! @relates hana::integral_constant template <int i> using int_ = integral_constant<int, i>; //! @relates hana::integral_constant template <int i> constexpr int_<i> int_c{}; //! @relates hana::integral_constant template <unsigned int i> using uint = integral_constant<unsigned int, i>; //! @relates hana::integral_constant template <unsigned int i> constexpr uint<i> uint_c{}; //! @relates hana::integral_constant template <long i> using long_ = integral_constant<long, i>; //! @relates hana::integral_constant template <long i> constexpr long_<i> long_c{}; //! @relates hana::integral_constant template <unsigned long i> using ulong = integral_constant<unsigned long, i>; //! @relates hana::integral_constant template <unsigned long i> constexpr ulong<i> ulong_c{}; //! @relates hana::integral_constant template <long long i> using llong = integral_constant<long long, i>; //! @relates hana::integral_constant template <long long i> constexpr llong<i> llong_c{}; //! @relates hana::integral_constant template <unsigned long long i> using ullong = integral_constant<unsigned long long, i>; //! @relates hana::integral_constant template <unsigned long long i> constexpr ullong<i> ullong_c{}; //! @relates hana::integral_constant template <std::size_t i> using size_t = integral_constant<std::size_t, i>; //! @relates hana::integral_constant template <std::size_t i> constexpr size_t<i> size_c{}; namespace literals { //! Creates a `hana::integral_constant` from a literal. //! @relatesalso boost::hana::integral_constant //! //! The literal is parsed at compile-time and the result is returned //! as a `llong<...>`. //! //! @note //! We use `llong<...>` instead of `ullong<...>` because using an //! unsigned type leads to unexpected behavior when doing stuff like //! `-1_c`. If we used an unsigned type, `-1_c` would be something //! like `ullong<-1>` which is actually `ullong<something huge>`. //! //! //! Example //! ------- //! @snippet example/integral_constant.cpp literals template <char ...c> constexpr auto operator"" _c(); } BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_INTEGRAL_CONSTANT_HPP PK �|!\�S��� � transform.hppnu �[��� /*! @file Forward declares `boost::hana::transform`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_TRANSFORM_HPP #define BOOST_HANA_FWD_TRANSFORM_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Map a function over a `Functor`. //! @ingroup group-Functor //! //! //! Signature //! --------- //! Given `F` a Functor, the signature is //! \f$ //! \mathtt{transform} : F(T) \times (T \to U) \to F(U) //! \f$ //! //! @param xs //! The structure to map `f` over. //! //! @param f //! A function called as `f(x)` on element(s) `x` of the structure, //! and returning a new value to replace `x` in the structure. //! //! //! Example //! ------- //! @include example/transform.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto transform = [](auto&& xs, auto&& f) { return tag-dispatched; }; #else template <typename Xs, typename = void> struct transform_impl : transform_impl<Xs, when<true>> { }; struct transform_t { template <typename Xs, typename F> constexpr auto operator()(Xs&& xs, F&& f) const; }; constexpr transform_t transform{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_TRANSFORM_HPP PK �|!\��_/� � replicate.hppnu �[��� /*! @file Forward declares `boost::hana::replicate`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_REPLICATE_HPP #define BOOST_HANA_FWD_REPLICATE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Create a monadic structure by combining a lifted value with itself //! `n` times. //! @ingroup group-MonadPlus //! //! Given a value `x`, a non-negative `IntegralConstant` `n` and the tag //! of a monadic structure `M`, `replicate` creates a new monadic structure //! which is the result of combining `x` with itself `n` times inside the //! monadic structure. In other words, `replicate` simply `lift`s `x` into //! the monadic structure, and then combines that with itself `n` times: //! @code //! replicate<M>(x, n) == cycle(lift<M>(x), n) //! @endcode //! //! If `n` is zero, then the identity of the `concat` operation is returned. //! In the case of sequences, this corresponds to creating a new sequence //! holding `n` copies of `x`. //! //! //! Signature //! --------- //! Given an `IntegralConstant` `C` and MonadPlus `M`, the signature is //! @f$ \mathtt{replicate}_M : T \times C \to M(T) @f$. //! //! @tparam M //! The tag of the returned monadic structure. It must be a //! model of the MonadPlus concept. //! //! @param x //! The value to lift into a monadic structure and then combine with //! itself. //! //! @param n //! A non-negative `IntegralConstant` representing the number of times to //! combine `lift<M>(x)` with itself. If `n == 0`, `replicate` returns //! `empty<M>()`. //! //! //! Example //! ------- //! @include example/replicate.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename M> constexpr auto replicate = [](auto&& x, auto const& n) { return tag-dispatched; }; #else template <typename M, typename = void> struct replicate_impl : replicate_impl<M, when<true>> { }; template <typename M> struct replicate_t { template <typename X, typename N> constexpr auto operator()(X&& x, N const& n) const; }; template <typename M> constexpr replicate_t<M> replicate{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_REPLICATE_HPP PK �|!\s��h h range.hppnu �[��� /*! @file Forward declares `boost::hana::range`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_RANGE_HPP #define BOOST_HANA_FWD_RANGE_HPP #include <boost/hana/config.hpp> #include <boost/hana/fwd/core/make.hpp> #include <boost/hana/fwd/integral_constant.hpp> BOOST_HANA_NAMESPACE_BEGIN #ifdef BOOST_HANA_DOXYGEN_INVOKED //! @ingroup group-datatypes //! Compile-time half-open interval of `hana::integral_constant`s. //! //! A `range` represents a half-open interval of the form `[from, to)` //! containing `hana::integral_constant`s of a given type. The `[from, to)` //! notation represents the values starting at `from` (inclusively) up //! to but excluding `from`. In other words, it is a bit like the list //! `from, from+1, ..., to-1`. //! //! In particular, note that the bounds of the range can be any //! `hana::integral_constant`s (negative numbers are allowed) and the //! range does not have to start at zero. The only requirement is that //! `from <= to`. //! //! @note //! The representation of `hana::range` is implementation defined. In //! particular, one should not take for granted the number and types //! of template parameters. The proper way to create a `hana::range` //! is to use `hana::range_c` or `hana::make_range`. More details //! [in the tutorial](@ref tutorial-containers-types). //! //! //! Modeled concepts //! ---------------- //! 1. `Comparable`\n //! Two ranges are equal if and only if they are both empty or they both //! span the same interval. //! @include example/range/comparable.cpp //! //! 2. `Foldable`\n //! Folding a `range` is equivalent to folding a list of the //! `integral_constant`s in the interval it spans. //! @include example/range/foldable.cpp //! //! 3. `Iterable`\n //! Iterating over a `range` is equivalent to iterating over a list of //! the values it spans. In other words, iterating over the range //! `[from, to)` is equivalent to iterating over a list containing //! `from, from+1, from+2, ..., to-1`. Also note that `operator[]` can //! be used in place of the `at` function. //! @include example/range/iterable.cpp //! //! 4. `Searchable`\n //! Searching a `range` is equivalent to searching a list of the values //! in the range `[from, to)`, but it is much more compile-time efficient. //! @include example/range/searchable.cpp template <typename T, T from, T to> struct range { //! Equivalent to `hana::equal` template <typename X, typename Y> friend constexpr auto operator==(X&& x, Y&& y); //! Equivalent to `hana::not_equal` template <typename X, typename Y> friend constexpr auto operator!=(X&& x, Y&& y); //! Equivalent to `hana::at` template <typename N> constexpr decltype(auto) operator[](N&& n); }; #else template <typename T, T from, T to> struct range; #endif //! Tag representing a `hana::range`. //! @relates hana::range struct range_tag { }; #ifdef BOOST_HANA_DOXYGEN_INVOKED //! Create a `hana::range` representing a half-open interval of //! `integral_constant`s. //! @relates hana::range //! //! Given two `IntegralConstant`s `from` and `to`, `make<range_tag>` //! returns a `hana::range` representing the half-open interval of //! `integral_constant`s `[from, to)`. `from` and `to` must form a //! valid interval, which means that `from <= to` must be true. Otherwise, //! a compilation error is triggered. Also note that if `from` and `to` //! are `IntegralConstant`s with different underlying integral types, //! the created range contains `integral_constant`s whose underlying //! type is their common type. //! //! //! Example //! ------- //! @include example/range/make.cpp template <> constexpr auto make<range_tag> = [](auto const& from, auto const& to) { return range<implementation_defined>{implementation_defined}; }; #endif //! Alias to `make<range_tag>`; provided for convenience. //! @relates hana::range constexpr auto make_range = make<range_tag>; //! Shorthand to create a `hana::range` with the given bounds. //! @relates hana::range //! //! This shorthand is provided for convenience only and it is equivalent //! to `make_range`. Specifically, `range_c<T, from, to>` is such that //! @code //! range_c<T, from, to> == make_range(integral_c<T, from>, integral_c<T, to>) //! @endcode //! //! //! @tparam T //! The underlying integral type of the `integral_constant`s in the //! created range. //! //! @tparam from //! The inclusive lower bound of the created range. //! //! @tparam to //! The exclusive upper bound of the created range. //! //! //! Example //! ------- //! @include example/range/range_c.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename T, T from, T to> constexpr auto range_c = make_range(integral_c<T, from>, integral_c<T, to>); #else template <typename T, T from, T to> constexpr range<T, from, to> range_c{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_RANGE_HPP PK �|!\��ɀ � scan_left.hppnu �[��� /*! @file Forward declares `boost::hana::scan_left`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_SCAN_LEFT_HPP #define BOOST_HANA_FWD_SCAN_LEFT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Fold a Sequence to the left and return a list containing the //! successive reduction states. //! @ingroup group-Sequence //! //! Like `fold_left`, `scan_left` reduces a sequence to a single value //! using a binary operation. However, unlike `fold_left`, it builds up //! a sequence of the intermediary results computed along the way and //! returns that instead of only the final reduction state. Like //! `fold_left`, `scan_left` can be used with or without an initial //! reduction state. //! //! When the sequence is empty, two things may arise. If an initial state //! was provided, a singleton list containing that state is returned. //! Otherwise, if no initial state was provided, an empty list is //! returned. In particular, unlike for `fold_left`, using `scan_left` //! on an empty sequence without an initial state is not an error. //! //! More specifically, `scan_left([x1, ..., xn], state, f)` is a sequence //! whose `i`th element is equivalent to `fold_left([x1, ..., xi], state, f)`. //! The no-state variant is handled in an analogous way. For illustration, //! consider this left fold on a short sequence: //! @code //! fold_left([x1, x2, x3], state, f) == f(f(f(state, x1), x2), x3) //! @endcode //! //! The analogous sequence generated with `scan_left` will be //! @code //! scan_left([x1, x2, x3], state, f) == [ //! state, //! f(state, x1), //! f(f(state, x1), x2), //! f(f(f(state, x1), x2), x3) //! ] //! @endcode //! //! Similarly, consider this left fold (without an initial state) on //! a short sequence: //! @code //! fold_left([x1, x2, x3, x4], f) == f(f(f(x1, x2), x3), x4) //! @endcode //! //! The analogous sequence generated with `scan_left` will be //! @code //! scan_left([x1, x2, x3, x4], f) == [ //! x1, //! f(x1, x2), //! f(f(x1, x2), x3), //! f(f(f(x1, x2), x3), x4) //! ] //! @endcode //! //! @param xs //! The sequence to scan from the left. //! //! @param state //! The (optional) initial reduction state. //! //! @param f //! A binary function called as `f(state, x)`, where `state` is the //! result accumulated so far and `x` is an element in the sequence. //! If no initial state is provided, `f` is called as `f(x1, x2)`, //! where `x1` and `x2` are both elements of the sequence. //! //! //! Example //! ------- //! @include example/scan_left.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto scan_left = [](auto&& xs[, auto&& state], auto const& f) { return tag-dispatched; }; #else template <typename S, typename = void> struct scan_left_impl : scan_left_impl<S, when<true>> { }; struct scan_left_t { template <typename Xs, typename State, typename F> constexpr auto operator()(Xs&& xs, State&& state, F const& f) const; template <typename Xs, typename F> constexpr auto operator()(Xs&& xs, F const& f) const; }; constexpr scan_left_t scan_left{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_SCAN_LEFT_HPP PK �|!\ �� � none.hppnu �[��� /*! @file Forward declares `boost::hana::none`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_NONE_HPP #define BOOST_HANA_FWD_NONE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns whether all of the keys of the structure are false-valued. //! @ingroup group-Searchable //! //! The keys of the structure must be `Logical`s. If the structure is not //! finite, a true-valued key must appear at a finite "index" in order //! for this method to finish. //! //! //! Example //! ------- //! @include example/none.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto none = [](auto&& xs) -> decltype(auto) { return tag-dispatched; }; #else template <typename S, typename = void> struct none_impl : none_impl<S, when<true>> { }; struct none_t { template <typename Xs> constexpr auto operator()(Xs&& xs) const; }; constexpr none_t none{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_NONE_HPP PK �|!\� X� � find_if.hppnu �[��� /*! @file Forward declares `boost::hana::find_if`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FIND_IF_HPP #define BOOST_HANA_FWD_FIND_IF_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Finds the value associated to the first key satisfying a predicate. //! @ingroup group-Searchable //! //! Given a `Searchable` structure `xs` and a predicate `pred`, //! `find_if(xs, pred)` returns `just` the first element whose key //! satisfies the predicate, or `nothing` if there is no such element. //! //! //! @param xs //! The structure to be searched. //! //! @param predicate //! A function called as `predicate(k)`, where `k` is a key of the //! structure, and returning whether `k` is the key of the element //! being searched for. In the current version of the library, the //! predicate has to return an `IntegralConstant` holding a value //! that can be converted to `bool`. //! //! //! Example //! ------- //! @include example/find_if.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto find_if = [](auto&& xs, auto&& predicate) { return tag-dispatched; }; #else template <typename S, typename = void> struct find_if_impl : find_if_impl<S, when<true>> { }; struct find_if_t { template <typename Xs, typename Pred> constexpr auto operator()(Xs&& xs, Pred&& pred) const; }; constexpr find_if_t find_if{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FIND_IF_HPP PK �|!\���6 6 index_if.hppnu �[��� /*! @file Forward declares `boost::hana::index_if`. @copyright Louis Dionne 2013-2017 @copyright Jason Rice 2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_INDEX_IF_HPP #define BOOST_HANA_FWD_INDEX_IF_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Finds the value associated to the first key satisfying a predicate. //! @ingroup group-Iterable //! //! Given an `Iterable` structure `xs` and a predicate `pred`, //! `index_if(xs, pred)` returns a `hana::optional` containing an `IntegralConstant` //! of the index of the first element that satisfies the predicate or nothing //! if no element satisfies the predicate. //! //! //! @param xs //! The structure to be searched. //! //! @param predicate //! A function called as `predicate(x)`, where `x` is an element of the //! `Iterable` structure and returning whether `x` is the element being //! searched for. In the current version of the library, the predicate //! has to return an `IntegralConstant` holding a value that can be //! converted to `bool`. //! //! //! Example //! ------- //! @include example/index_if.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto index_if = [](auto&& xs, auto&& predicate) { return tag-dispatched; }; #else template <typename S, typename = void> struct index_if_impl : index_if_impl<S, when<true>> { }; struct index_if_t { template <typename Xs, typename Pred> constexpr auto operator()(Xs&& xs, Pred&& pred) const; }; constexpr index_if_t index_if{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_INDEX_IF_HPP PK �|!\&��G� � take_while.hppnu �[��� /*! @file Forward declares `boost::hana::take_while`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_TAKE_WHILE_HPP #define BOOST_HANA_FWD_TAKE_WHILE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Take elements from a sequence while the `predicate` is satisfied. //! @ingroup group-Sequence //! //! Specifically, `take_while` returns a new sequence containing the //! longest prefix of `xs` in which all the elements satisfy the given //! predicate. //! //! //! @param xs //! The sequence to take elements from. //! //! @param predicate //! A function called as `predicate(x)`, where `x` is an element of the //! sequence, and returning a `Logical` representing whether `x` should be //! included in the resulting sequence. In the current version of the //! library, `predicate` has to return a `Constant Logical`. //! //! //! Example //! ------- //! @include example/take_while.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto take_while = [](auto&& xs, auto&& predicate) { return tag-dispatched; }; #else template <typename S, typename = void> struct take_while_impl : take_while_impl<S, when<true>> { }; struct take_while_t { template <typename Xs, typename Pred> constexpr auto operator()(Xs&& xs, Pred&& pred) const; }; constexpr take_while_t take_while{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_TAKE_WHILE_HPP PK �|!\�m~< < adapt_adt.hppnu �[��� /*! @file Documents the `BOOST_HANA_ADAPT_ADT` macro. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ADAPT_ADT_HPP #define BOOST_HANA_FWD_ADAPT_ADT_HPP #include <boost/hana/config.hpp> BOOST_HANA_NAMESPACE_BEGIN // Note: // The weird definition as a variable seems to exploit a glitch in Doxygen // which makes the macro appear in the related objects of Struct (as we // want it to). //! Defines a model of `Struct` with the given accessors. //! @ingroup group-Struct //! //! Using this macro at _global scope_ will define a model of the `Struct` //! concept for the given type. This can be used to easily adapt existing //! user-defined types in a ad-hoc manner. Unlike `BOOST_HANA_ADAPT_STRUCT`, //! this macro requires specifying the way to retrieve each member by //! providing a function that does the extraction. //! //! @note //! This macro only works if the tag of the user-defined type `T` is `T` //! itself. This is the case unless you specifically asked for something //! different; see `tag_of`'s documentation. //! //! //! Example //! ------- //! @include example/adapt_adt.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED auto BOOST_HANA_ADAPT_ADT(...) = ; #define BOOST_HANA_ADAPT_ADT(Name, ...) see documentation #else // defined in <boost/hana/adapt_adt.hpp> #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ADAPT_ADT_HPP PK �|!\7oqdI dI optional.hppnu �[��� /*! @file Forward declares `boost::hana::optional`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_OPTIONAL_HPP #define BOOST_HANA_FWD_OPTIONAL_HPP #include <boost/hana/config.hpp> #include <boost/hana/detail/operators/adl.hpp> #include <boost/hana/fwd/core/make.hpp> BOOST_HANA_NAMESPACE_BEGIN //! @ingroup group-datatypes //! Optional value whose optional-ness is known at compile-time. //! //! An `optional` either contains a value (represented as `just(x)`), or //! it is empty (represented as `nothing`). In essence, `hana::optional` //! is pretty much like a `boost::optional` or the upcoming `std::optional`, //! except for the fact that whether a `hana::optional` is empty or not is //! known at compile-time. This can be particularly useful for returning //! from a function that might fail, but whose reason for failing is not //! important. Of course, whether the function will fail has to be known //! at compile-time. //! //! This is really an important difference between `hana::optional` and //! `std::optional`. Unlike `std::optional<T>{}` and `std::optional<T>{x}` //! who share the same type (`std::optional<T>`), `hana::just(x)` and //! `hana::nothing` do not share the same type, since the state of the //! optional has to be known at compile-time. Hence, whether a `hana::just` //! or a `hana::nothing` will be returned from a function has to be known //! at compile-time for the return type of that function to be computable //! by the compiler. This makes `hana::optional` well suited for static //! metaprogramming tasks, but very poor for anything dynamic. //! //! @note //! When you use a container, remember not to make assumptions about its //! representation, unless the documentation gives you those guarantees. //! More details [in the tutorial](@ref tutorial-containers-types). //! //! //! Interoperation with `type`s //! --------------------------- //! When a `just` contains an object of type `T` which is a `type`, //! it has a nested `::%type` alias equivalent to `T::%type`. `nothing`, //! however, never has a nested `::%type` alias. If `t` is a `type`, //! this allows `decltype(just(t))` to be seen as a nullary metafunction //! equivalent to `decltype(t)`. Along with the `sfinae` function, //! this allows `hana::optional` to interact seamlessly with //! SFINAE-friendly metafunctions. //! Example: //! @include example/optional/sfinae_friendly_metafunctions.cpp //! //! //! Modeled concepts //! ---------------- //! 1. `Comparable`\n //! Two `optional`s are equal if and only if they are both empty or they //! both contain a value and those values are equal. //! @include example/optional/comparable.cpp //! //! 2. `Orderable`\n //! Optional values can be ordered by considering the value they are //! holding, if any. To handle the case of an empty optional value, we //! arbitrarily set `nothing` as being less than any other `just`. Hence, //! @code //! just(x) < just(y) if and only if x < y //! nothing < just(anything) //! @endcode //! Example: //! @include example/optional/orderable.cpp //! //! 3. `Functor`\n //! An optional value can be seen as a list containing either one element //! (`just(x)`) or no elements at all (`nothing`). As such, mapping //! a function over an optional value is equivalent to applying it to //! its value if there is one, and to `nothing` otherwise: //! @code //! transform(just(x), f) == just(f(x)) //! transform(nothing, f) == nothing //! @endcode //! Example: //! @include example/optional/functor.cpp //! //! 4. `Applicative`\n //! First, a value can be made optional with `lift<optional_tag>`, which //! is equivalent to `just`. Second, one can feed an optional value to an //! optional function with `ap`, which will return `just(f(x))` if there //! is both a function _and_ a value, and `nothing` otherwise: //! @code //! ap(just(f), just(x)) == just(f(x)) //! ap(nothing, just(x)) == nothing //! ap(just(f), nothing) == nothing //! ap(nothing, nothing) == nothing //! @endcode //! A simple example: //! @include example/optional/applicative.cpp //! A more complex example: //! @include example/optional/applicative.complex.cpp //! //! 5. `Monad`\n //! The `Monad` model makes it easy to compose actions that might fail. //! One can feed an optional value if there is one into a function with //! `chain`, which will return `nothing` if there is no value. Finally, //! optional-optional values can have their redundant level of optionality //! removed with `flatten`. Also note that the `|` operator can be used in //! place of the `chain` function. //! Example: //! @include example/optional/monad.cpp //! //! 6. `MonadPlus`\n //! The `MonadPlus` model allows choosing the first valid value out of //! two optional values with `concat`. If both optional values are //! `nothing`s, `concat` will return `nothing`. //! Example: //! @include example/optional/monad_plus.cpp //! //! 7. `Foldable`\n //! Folding an optional value is equivalent to folding a list containing //! either no elements (for `nothing`) or `x` (for `just(x)`). //! Example: //! @include example/optional/foldable.cpp //! //! 8. `Searchable`\n //! Searching an optional value is equivalent to searching a list //! containing `x` for `just(x)` and an empty list for `nothing`. //! Example: //! @include example/optional/searchable.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename ...T> struct optional { // 5.3.1, Constructors //! Default-construct an `optional`. Only exists if the optional //! contains a value, and if that value is DefaultConstructible. constexpr optional() = default; //! Copy-construct an `optional`. //! An empty optional may only be copy-constructed from another //! empty `optional`, and an `optional` with a value may only be //! copy-constructed from another `optional` with a value. //! Furthermore, this constructor only exists if the value //! held in the `optional` is CopyConstructible. optional(optional const&) = default; //! Move-construct an `optional`. //! An empty optional may only be move-constructed from another //! empty `optional`, and an `optional` with a value may only be //! move-constructed from another `optional` with a value. //! Furthermore, this constructor only exists if the value //! held in the `optional` is MoveConstructible. optional(optional&&) = default; //! Construct an `optional` holding a value of type `T` from another //! object of type `T`. The value is copy-constructed. constexpr optional(T const& t) : value_(t) { } //! Construct an `optional` holding a value of type `T` from another //! object of type `T`. The value is move-constructed. constexpr optional(T&& t) : value_(static_cast<T&&>(t)) { } // 5.3.3, Assignment //! Copy-assign an `optional`. //! An empty optional may only be copy-assigned from another empty //! `optional`, and an `optional` with a value may only be copy-assigned //! from another `optional` with a value. Furthermore, this assignment //! operator only exists if the value held in the `optional` is //! CopyAssignable. constexpr optional& operator=(optional const&) = default; //! Move-assign an `optional`. //! An empty optional may only be move-assigned from another empty //! `optional`, and an `optional` with a value may only be move-assigned //! from another `optional` with a value. Furthermore, this assignment //! operator only exists if the value held in the `optional` is //! MoveAssignable. constexpr optional& operator=(optional&&) = default; // 5.3.5, Observers //! Returns a pointer to the contained value, or a `nullptr` if the //! `optional` is empty. //! //! //! @note Overloads of this method are provided for both the `const` //! and the non-`const` cases. //! //! //! Example //! ------- //! @include example/optional/value.cpp constexpr T* operator->(); //! Extract the content of an `optional`, or fail at compile-time. //! //! If `*this` contains a value, that value is returned. Otherwise, //! a static assertion is triggered. //! //! @note //! Overloads of this method are provided for the cases where `*this` //! is a reference, a rvalue-reference and their `const` counterparts. //! //! //! Example //! ------- //! @include example/optional/value.cpp constexpr T& value(); //! Equivalent to `value()`, provided for convenience. //! //! @note //! Overloads of this method are provided for the cases where `*this` //! is a reference, a rvalue-reference and their `const` counterparts. //! //! //! Example //! ------- //! @include example/optional/value.cpp constexpr T& operator*(); //! Return the contents of an `optional`, with a fallback result. //! //! If `*this` contains a value, that value is returned. Otherwise, //! the default value provided is returned. //! //! @note //! Overloads of this method are provided for the cases where `*this` //! is a reference, a rvalue-reference and their `const` counterparts. //! //! //! @param default_ //! The default value to return if `*this` does not contain a value. //! //! //! Example //! ------- //! @include example/optional/value_or.cpp template <typename U> constexpr decltype(auto) value_or(U&& default_); //! Equivalent to `hana::chain`. template <typename ...T, typename F> friend constexpr auto operator|(optional<T...>, F); //! Equivalent to `hana::equal` template <typename X, typename Y> friend constexpr auto operator==(X&& x, Y&& y); //! Equivalent to `hana::not_equal` template <typename X, typename Y> friend constexpr auto operator!=(X&& x, Y&& y); //! Equivalent to `hana::less` template <typename X, typename Y> friend constexpr auto operator<(X&& x, Y&& y); //! Equivalent to `hana::greater` template <typename X, typename Y> friend constexpr auto operator>(X&& x, Y&& y); //! Equivalent to `hana::less_equal` template <typename X, typename Y> friend constexpr auto operator<=(X&& x, Y&& y); //! Equivalent to `hana::greater_equal` template <typename X, typename Y> friend constexpr auto operator>=(X&& x, Y&& y); }; #else template <typename ...T> struct optional; #endif //! Tag representing a `hana::optional`. //! @relates hana::optional struct optional_tag { }; //! Create an optional value. //! @relates hana::optional //! //! Specifically, `make<optional_tag>()` is equivalent to `nothing`, and //! `make<optional_tag>(x)` is equivalent to `just(x)`. This is provided //! for consistency with the other `make<...>` functions. //! //! //! Example //! ------- //! @include example/optional/make.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <> constexpr auto make<optional_tag> = []([auto&& x]) { return optional<std::decay<decltype(x)>::type>{forwarded(x)}; }; #endif //! Alias to `make<optional_tag>`; provided for convenience. //! @relates hana::optional //! //! //! Example //! ------- //! @include example/optional/make.cpp constexpr auto make_optional = make<optional_tag>; //! Create an optional value containing `x`. //! @relates hana::optional //! //! //! Example //! ------- //! @include example/optional/just.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto just = [](auto&& x) { return optional<std::decay<decltype(x)>::type>{forwarded(x)}; }; #else struct make_just_t { template <typename T> constexpr auto operator()(T&&) const; }; constexpr make_just_t just{}; #endif //! An empty optional value. //! @relates hana::optional //! //! //! Example //! ------- //! @include example/optional/nothing.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr optional<> nothing{}; #else template <> struct optional<> : detail::operators::adl<optional<>> { // 5.3.1, Constructors constexpr optional() = default; constexpr optional(optional const&) = default; constexpr optional(optional&&) = default; // 5.3.3, Assignment constexpr optional& operator=(optional const&) = default; constexpr optional& operator=(optional&&) = default; // 5.3.5, Observers constexpr decltype(nullptr) operator->() const { return nullptr; } template <typename ...dummy> constexpr auto value() const; template <typename ...dummy> constexpr auto operator*() const; template <typename U> constexpr U&& value_or(U&& u) const; }; constexpr optional<> nothing{}; #endif //! Apply a function to the contents of an optional, with a fallback //! result. //! @relates hana::optional //! //! Specifically, `maybe` takes a default value, a function and an //! optional value. If the optional value is `nothing`, the default //! value is returned. Otherwise, the function is applied to the //! content of the `just`. //! //! //! @param default_ //! A default value returned if `m` is `nothing`. //! //! @param f //! A function called as `f(x)` if and only if `m` is an optional value //! of the form `just(x)`. In that case, the result returend by `maybe` //! is the result of `f`. //! //! @param m //! An optional value. //! //! //! Example //! ------- //! @include example/optional/maybe.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto maybe = [](auto&& default_, auto&& f, auto&& m) -> decltype(auto) { if (m is a just(x)) { return forwarded(f)(forwarded(x)); else return forwarded(default_); } }; #else struct maybe_t { template <typename Def, typename F, typename T> constexpr decltype(auto) operator()(Def&&, F&& f, optional<T> const& m) const { return static_cast<F&&>(f)(m.value_); } template <typename Def, typename F, typename T> constexpr decltype(auto) operator()(Def&&, F&& f, optional<T>& m) const { return static_cast<F&&>(f)(m.value_); } template <typename Def, typename F, typename T> constexpr decltype(auto) operator()(Def&&, F&& f, optional<T>&& m) const { return static_cast<F&&>(f)(static_cast<optional<T>&&>(m).value_); } template <typename Def, typename F> constexpr Def operator()(Def&& def, F&&, optional<> const&) const { return static_cast<Def&&>(def); } }; constexpr maybe_t maybe{}; #endif //! Calls a function if the call expression is well-formed. //! @relates hana::optional //! //! Given a function `f`, `sfinae` returns a new function applying `f` //! to its arguments and returning `just` the result if the call is //! well-formed, and `nothing` otherwise. In other words, `sfinae(f)(x...)` //! is `just(f(x...))` if that expression is well-formed, and `nothing` //! otherwise. Note, however, that it is possible for an expression //! `f(x...)` to be well-formed as far as SFINAE is concerned, but //! trying to actually compile `f(x...)` still fails. In this case, //! `sfinae` won't be able to detect it and a hard failure is likely //! to happen. //! //! //! @note //! The function given to `sfinae` must not return `void`, since //! `just(void)` does not make sense. A compilation error is //! triggered if the function returns void. //! //! //! Example //! ------- //! @include example/optional/sfinae.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED auto sfinae = [](auto&& f) { return [perfect-capture](auto&& ...x) { if (decltype(forwarded(f)(forwarded(x)...)) is well-formed) return just(forwarded(f)(forwarded(x)...)); else return nothing; }; }; #else struct sfinae_t { template <typename F> constexpr decltype(auto) operator()(F&& f) const; }; constexpr sfinae_t sfinae{}; #endif //! Return whether an `optional` contains a value. //! @relates hana::optional //! //! Specifically, returns a compile-time true-valued `Logical` if `m` is //! of the form `just(x)` for some `x`, and a false-valued one otherwise. //! //! //! Example //! ------- //! @include example/optional/is_just.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto is_just = [](auto const& m) { return m is a just(x); }; #else struct is_just_t { template <typename ...T> constexpr auto operator()(optional<T...> const&) const; }; constexpr is_just_t is_just{}; #endif //! Return whether an `optional` is empty. //! @relates hana::optional //! //! Specifically, returns a compile-time true-valued `Logical` if `m` is //! a `nothing`, and a false-valued one otherwise. //! //! //! Example //! ------- //! @include example/optional/is_nothing.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto is_nothing = [](auto const& m) { return m is a nothing; }; #else struct is_nothing_t { template <typename ...T> constexpr auto operator()(optional<T...> const&) const; }; constexpr is_nothing_t is_nothing{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_OPTIONAL_HPP PK �|!\m� at_key.hppnu �[��� /*! @file Forward declares `boost::hana::at_key`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_AT_KEY_HPP #define BOOST_HANA_FWD_AT_KEY_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns the value associated to the given key in a structure, or fail. //! @ingroup group-Searchable //! //! Given a `key` and a `Searchable` structure, `at_key` returns the first //! value whose key is equal to the given `key`, and fails at compile-time //! if no such key exists. This requires the `key` to be compile-time //! `Comparable`, exactly like for `find`. `at_key` satisfies the following: //! @code //! at_key(xs, key) == find(xs, key).value() //! @endcode //! //! If the `Searchable` actually stores the elements it contains, `at_key` //! is required to return a lvalue reference, a lvalue reference to const //! or a rvalue reference to the found value, where the type of reference //! must match that of the structure passed to `at_key`. If the `Searchable` //! does not store the elements it contains (i.e. it generates them on //! demand), this requirement is dropped. //! //! //! @param xs //! The structure to be searched. //! //! @param key //! A key to be searched for in the structure. The key has to be //! `Comparable` with the other keys of the structure. In the current //! version of the library, the comparison of `key` with any other key //! of the structure must return a compile-time `Logical`. //! //! //! Example //! ------- //! @include example/at_key.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto at_key = [](auto&& xs, auto const& key) -> decltype(auto) { return tag-dispatched; }; #else template <typename S, typename = void> struct at_key_impl : at_key_impl<S, when<true>> { }; struct at_key_t { template <typename Xs, typename Key> constexpr decltype(auto) operator()(Xs&& xs, Key const& key) const; }; constexpr at_key_t at_key{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_AT_KEY_HPP PK �|!\c�ӑi i drop_front_exactly.hppnu �[��� /*! @file Forward declares `boost::hana::drop_front_exactly`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_DROP_FRONT_EXACTLY_HPP #define BOOST_HANA_FWD_DROP_FRONT_EXACTLY_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Drop the first `n` elements of an iterable, and return the rest. //! @ingroup group-Iterable //! //! Given an `Iterable` `xs` with a linearization of `[x1, x2, ...]` and //! a non-negative `IntegralConstant` `n`, `drop_front_exactly(xs, n)` is //! an iterable with the same tag as `xs` whose linearization is //! `[xn+1, xn+2, ...]`. In particular, note that this function does not //! mutate the original iterable in any way. If `n` is not given, it //! defaults to an `IntegralConstant` with a value equal to `1`. //! //! It is an error to use `drop_front_exactly` with `n > length(xs)`. This //! additional guarantee allows `drop_front_exactly` to be better optimized //! than the `drop_front` function, which allows `n > length(xs)`. //! //! //! @param xs //! The iterable from which elements are dropped. //! //! @param n //! A non-negative `IntegralConstant` representing the number of elements //! to be dropped from the iterable. In addition to being non-negative, //! `n` must be less than or equal to the number of elements in `xs`. //! If `n` is not given, it defaults to an `IntegralConstant` with a value //! equal to `1`. //! //! //! Example //! ------- //! @include example/drop_front_exactly.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto drop_front_exactly = [](auto&& xs[, auto const& n]) { return tag-dispatched; }; #else template <typename It, typename = void> struct drop_front_exactly_impl : drop_front_exactly_impl<It, when<true>> { }; struct drop_front_exactly_t { template <typename Xs, typename N> constexpr auto operator()(Xs&& xs, N const& n) const; template <typename Xs> constexpr auto operator()(Xs&& xs) const; }; constexpr drop_front_exactly_t drop_front_exactly{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_DROP_FRONT_EXACTLY_HPP PK �|!\4?֎� � symmetric_difference.hppnu �[��� /*! @file Forward declares `boost::hana::symmetric_difference`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_SYMMETRIC_DIFFERENCE_HPP #define BOOST_HANA_FWD_SYMMETRIC_DIFFERENCE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN // Note: This function is documented per datatype/concept only. //! @cond template <typename S, typename = void> struct symmetric_difference_impl : symmetric_difference_impl<S, when<true>> { }; //! @endcond struct symmetric_difference_t { template <typename Xs, typename Ys> constexpr auto operator()(Xs&&, Ys&&) const; }; constexpr symmetric_difference_t symmetric_difference{}; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_SYMMETRIC_DIFFERENCE_HPP PK �|!\T�d�M �M type.hppnu �[��� /*! @file Forward declares `boost::hana::type` and related utilities. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_TYPE_HPP #define BOOST_HANA_FWD_TYPE_HPP #include <boost/hana/config.hpp> #include <boost/hana/fwd/core/make.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Base class of `hana::type`; used for pattern-matching. //! @relates hana::type //! //! Example //! ------- //! @include example/type/basic_type.cpp template <typename T> struct basic_type; //! @ingroup group-datatypes //! C++ type in value-level representation. //! //! A `type` is a special kind of object representing a C++ type like //! `int`, `void`, `std::vector<float>` or anything else you can imagine. //! //! This page explains how `type`s work at a low level. To gain //! intuition about type-level metaprogramming in Hana, you should //! read the [tutorial section](@ref tutorial-type) on type-level //! computations. //! //! //! @note //! For subtle reasons, the actual representation of `hana::type` is //! implementation-defined. In particular, `hana::type` may be a dependent //! type, so one should not attempt to do pattern matching on it. However, //! one can assume that `hana::type` _inherits_ from `hana::basic_type`, //! which can be useful when declaring overloaded functions: //! @code //! template <typename T> //! void f(hana::basic_type<T>) { //! // do something with T //! } //! @endcode //! The full story is that [ADL][] causes template arguments to be //! instantiated. Hence, if `hana::type` were defined naively, expressions //! like `hana::type<T>{} == hana::type<U>{}` would cause both `T` and `U` //! to be instantiated. This is usually not a problem, except when `T` or //! `U` should not be instantiated. To avoid these instantiations, //! `hana::type` is implemented using some cleverness, and that is //! why the representation is implementation-defined. When that //! behavior is not required, `hana::basic_type` can be used instead. //! //! //! @anchor type_lvalues_and_rvalues //! Lvalues and rvalues //! ------------------- //! When storing `type`s in heterogeneous containers, some algorithms //! will return references to those objects. Since we are primarily //! interested in accessing their nested `::%type`, receiving a reference //! is undesirable; we would end up trying to fetch the nested `::%type` //! inside a reference type, which is a compilation error: //! @code //! auto ts = make_tuple(type_c<int>, type_c<char>); //! using T = decltype(ts[0_c])::type; // error: 'ts[0_c]' is a reference! //! @endcode //! //! For this reason, `type`s provide an overload of the unary `+` //! operator that can be used to turn a lvalue into a rvalue. So when //! using a result which might be a reference to a `type` object, one //! can use `+` to make sure a rvalue is obtained before fetching its //! nested `::%type`: //! @code //! auto ts = make_tuple(type_c<int>, type_c<char>); //! using T = decltype(+ts[0_c])::type; // ok: '+ts[0_c]' is an rvalue //! @endcode //! //! //! Modeled concepts //! ---------------- //! 1. `Comparable`\n //! Two types are equal if and only if they represent the same C++ type. //! Hence, equality is equivalent to the `std::is_same` type trait. //! @include example/type/comparable.cpp //! //! 2. `Hashable`\n //! The hash of a type is just that type itself. In other words, `hash` //! is the identity function on `hana::type`s. //! @include example/type/hashable.cpp //! //! [ADL]: http://en.cppreference.com/w/cpp/language/adl #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename T> struct type { //! Returns rvalue of self. //! See @ref type_lvalues_and_rvalues "description". constexpr auto operator+() const; //! Equivalent to `hana::equal` template <typename X, typename Y> friend constexpr auto operator==(X&& x, Y&& y); //! Equivalent to `hana::not_equal` template <typename X, typename Y> friend constexpr auto operator!=(X&& x, Y&& y); }; #else template <typename T> struct type_impl; template <typename T> using type = typename type_impl<T>::_; #endif //! Tag representing `hana::type`. //! @relates hana::type struct type_tag { }; //! Creates an object representing the C++ type `T`. //! @relates hana::type template <typename T> constexpr type<T> type_c{}; //! `decltype` keyword, lifted to Hana. //! @relates hana::type //! //! @deprecated //! The semantics of `decltype_` can be confusing, and `hana::typeid_` //! should be preferred instead. `decltype_` may be removed in the next //! major version of the library. //! //! `decltype_` is somewhat equivalent to `decltype` in that it returns //! the type of an object, except it returns it as a `hana::type` which //! is a first-class citizen of Hana instead of a raw C++ type. //! Specifically, given an object `x`, `decltype_` satisfies //! @code //! decltype_(x) == type_c<decltype(x) with references stripped> //! @endcode //! //! As you can see, `decltype_` will strip any reference from the //! object's actual type. The reason for doing so is explained below. //! However, any `cv`-qualifiers will be retained. Also, when given a //! `hana::type`, `decltype_` is just the identity function. Hence, //! for any C++ type `T`, //! @code //! decltype_(type_c<T>) == type_c<T> //! @endcode //! //! In conjunction with the way `metafunction` & al. are specified, this //! behavior makes it easier to interact with both types and values at //! the same time. However, it does make it impossible to create a `type` //! containing another `type` with `decltype_`. In other words, it is //! not possible to create a `type_c<decltype(type_c<T>)>` with this //! utility, because `decltype_(type_c<T>)` would be just `type_c<T>` //! instead of `type_c<decltype(type_c<T>)>`. This use case is assumed //! to be rare and a hand-coded function can be used if this is needed. //! //! //! ### Rationale for stripping the references //! The rules for template argument deduction are such that a perfect //! solution that always matches `decltype` is impossible. Hence, we //! have to settle on a solution that's good and and consistent enough //! for our needs. One case where matching `decltype`'s behavior is //! impossible is when the argument is a plain, unparenthesized variable //! or function parameter. In that case, `decltype_`'s argument will be //! deduced as a reference to that variable, but `decltype` would have //! given us the actual type of that variable, without references. Also, //! given the current definition of `metafunction` & al., it would be //! mostly useless if `decltype_` could return a reference, because it //! is unlikely that `F` expects a reference in its simplest use case: //! @code //! int i = 0; //! auto result = metafunction<F>(i); //! @endcode //! //! Hence, always discarding references seems to be the least painful //! solution. //! //! //! Example //! ------- //! @include example/type/decltype.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto decltype_ = see documentation; #else struct decltype_t { template <typename T> constexpr auto operator()(T&&) const; }; constexpr decltype_t decltype_{}; #endif //! Returns a `hana::type` representing the type of a given object. //! @relates hana::type //! //! `hana::typeid_` is somewhat similar to `typeid` in that it returns //! something that represents the type of an object. However, what //! `typeid` returns represent the _runtime_ type of the object, while //! `hana::typeid_` returns the _static_ type of the object. Specifically, //! given an object `x`, `typeid_` satisfies //! @code //! typeid_(x) == type_c<decltype(x) with ref and cv-qualifiers stripped> //! @endcode //! //! As you can see, `typeid_` strips any reference and cv-qualifier from //! the object's actual type. The reason for doing so is that it faithfully //! models how the language's `typeid` behaves with respect to reference //! and cv-qualifiers, and it also turns out to be the desirable behavior //! most of the time. Also, when given a `hana::type`, `typeid_` is just //! the identity function. Hence, for any C++ type `T`, //! @code //! typeid_(type_c<T>) == type_c<T> //! @endcode //! //! In conjunction with the way `metafunction` & al. are specified, this //! behavior makes it easier to interact with both types and values at //! the same time. However, it does make it impossible to create a `type` //! containing another `type` using `typeid_`. This use case is assumed //! to be rare and a hand-coded function can be used if this is needed. //! //! //! Example //! ------- //! @include example/type/typeid.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto typeid_ = see documentation; #else struct typeid_t { template <typename T> constexpr auto operator()(T&&) const; }; constexpr typeid_t typeid_{}; #endif #ifdef BOOST_HANA_DOXYGEN_INVOKED //! Equivalent to `decltype_`, provided for convenience. //! @relates hana::type //! //! //! Example //! ------- //! @include example/type/make.cpp template <> constexpr auto make<type_tag> = hana::decltype_; #endif //! Equivalent to `make<type_tag>`, provided for convenience. //! @relates hana::type //! //! //! Example //! ------- //! @include example/type/make.cpp constexpr auto make_type = hana::make<type_tag>; //! `sizeof` keyword, lifted to Hana. //! @relates hana::type //! //! `sizeof_` is somewhat equivalent to `sizeof` in that it returns the //! size of an expression or type, but it takes an arbitrary expression //! or a `hana::type` and returns its size as an `integral_constant`. //! Specifically, given an expression `expr`, `sizeof_` satisfies //! @code //! sizeof_(expr) == size_t<sizeof(decltype(expr) with references stripped)> //! @endcode //! //! However, given a `type`, `sizeof_` will simply fetch the size //! of the C++ type represented by that object. In other words, //! @code //! sizeof_(type_c<T>) == size_t<sizeof(T)> //! @endcode //! //! The behavior of `sizeof_` is consistent with that of `decltype_`. //! In particular, see `decltype_`'s documentation to understand why //! references are always stripped by `sizeof_`. //! //! //! Example //! ------- //! @include example/type/sizeof.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto sizeof_ = [](auto&& x) { using T = typename decltype(hana::decltype_(x))::type; return hana::size_c<sizeof(T)>; }; #else struct sizeof_t { template <typename T> constexpr auto operator()(T&&) const; }; constexpr sizeof_t sizeof_{}; #endif //! `alignof` keyword, lifted to Hana. //! @relates hana::type //! //! `alignof_` is somewhat equivalent to `alignof` in that it returns the //! alignment required by any instance of a type, but it takes a `type` //! and returns its alignment as an `integral_constant`. Like `sizeof` //! which works for expressions and type-ids, `alignof_` can also be //! called on an arbitrary expression. Specifically, given an expression //! `expr` and a C++ type `T`, `alignof_` satisfies //! @code //! alignof_(expr) == size_t<alignof(decltype(expr) with references stripped)> //! alignof_(type_c<T>) == size_t<alignof(T)> //! @endcode //! //! The behavior of `alignof_` is consistent with that of `decltype_`. //! In particular, see `decltype_`'s documentation to understand why //! references are always stripped by `alignof_`. //! //! //! Example //! ------- //! @include example/type/alignof.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto alignof_ = [](auto&& x) { using T = typename decltype(hana::decltype_(x))::type; return hana::size_c<alignof(T)>; }; #else struct alignof_t { template <typename T> constexpr auto operator()(T&&) const; }; constexpr alignof_t alignof_{}; #endif //! Checks whether a SFINAE-friendly expression is valid. //! @relates hana::type //! //! Given a SFINAE-friendly function, `is_valid` returns whether the //! function call is valid with the given arguments. Specifically, given //! a function `f` and arguments `args...`, //! @code //! is_valid(f, args...) == whether f(args...) is valid //! @endcode //! //! The result is returned as a compile-time `Logical`. Furthermore, //! `is_valid` can be used in curried form as follows: //! @code //! is_valid(f)(args...) //! @endcode //! //! This syntax makes it easy to create functions that check the validity //! of a generic expression on any given argument(s). //! //! @warning //! To check whether calling a nullary function `f` is valid, one should //! use the `is_valid(f)()` syntax. Indeed, `is_valid(f /* no args */)` //! will be interpreted as the currying of `is_valid` to `f` rather than //! the application of `is_valid` to `f` and no arguments. //! //! //! Example //! ------- //! @include example/type/is_valid.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto is_valid = [](auto&& f) { return [](auto&& ...args) { return whether f(args...) is a valid expression; }; }; #else struct is_valid_t { template <typename F> constexpr auto operator()(F&&) const; template <typename F, typename ...Args> constexpr auto operator()(F&&, Args&&...) const; }; constexpr is_valid_t is_valid{}; #endif //! Lift a template to a Metafunction. //! @ingroup group-Metafunction //! //! Given a template class or template alias `f`, `template_<f>` is a //! `Metafunction` satisfying //! @code //! template_<f>(type_c<x>...) == type_c<f<x...>> //! decltype(template_<f>)::apply<x...>::type == f<x...> //! @endcode //! //! @note //! In a SFINAE context, the expression `template_<f>(type_c<x>...)` is //! valid whenever the expression `f<x...>` is valid. //! //! //! Example //! ------- //! @include example/type/template.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <template <typename ...> class F> constexpr auto template_ = [](basic_type<T>...) { return hana::type_c<F<T...>>; }; #else template <template <typename ...> class F> struct template_t; template <template <typename ...> class F> constexpr template_t<F> template_{}; #endif //! Lift a MPL-style metafunction to a Metafunction. //! @ingroup group-Metafunction //! //! Given a MPL-style metafunction, `metafunction<f>` is a `Metafunction` //! satisfying //! @code //! metafunction<f>(type_c<x>...) == type_c<f<x...>::type> //! decltype(metafunction<f>)::apply<x...>::type == f<x...>::type //! @endcode //! //! @note //! In a SFINAE context, the expression `metafunction<f>(type_c<x>...)` is //! valid whenever the expression `f<x...>::%type` is valid. //! //! //! Example //! ------- //! @include example/type/metafunction.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <template <typename ...> class F> constexpr auto metafunction = [](basic_type<T>...) { return hana::type_c<typename F<T...>::type>; }; #else template <template <typename ...> class f> struct metafunction_t; template <template <typename ...> class f> constexpr metafunction_t<f> metafunction{}; #endif //! Lift a MPL-style metafunction class to a Metafunction. //! @ingroup group-Metafunction //! //! Given a MPL-style metafunction class, `metafunction_class<f>` is a //! `Metafunction` satisfying //! @code //! metafunction_class<f>(type_c<x>...) == type_c<f::apply<x...>::type> //! decltype(metafunction_class<f>)::apply<x...>::type == f::apply<x...>::type //! @endcode //! //! @note //! In a SFINAE context, the expression `metafunction_class<f>(type_c<x>...)` //! is valid whenever the expression `f::apply<x...>::%type` is valid. //! //! //! Example //! ------- //! @include example/type/metafunction_class.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename F> constexpr auto metafunction_class = [](basic_type<T>...) { return hana::type_c<typename F::template apply<T...>::type>; }; #else template <typename F> struct metafunction_class_t; template <typename F> constexpr metafunction_class_t<F> metafunction_class{}; #endif //! Turn a `Metafunction` into a function taking `type`s and returning a //! default-constructed object. //! @ingroup group-Metafunction //! //! Given a `Metafunction` `f`, `integral` returns a new `Metafunction` //! that default-constructs an object of the type returned by `f`. More //! specifically, the following holds: //! @code //! integral(f)(t...) == decltype(f(t...))::type{} //! @endcode //! //! The principal use case for `integral` is to transform `Metafunction`s //! returning a type that inherits from a meaningful base like //! `std::integral_constant` into functions returning e.g. a //! `hana::integral_constant`. //! //! @note //! - This is not a `Metafunction` because it does not return a `type`. //! As such, it would not make sense to make `decltype(integral(f))` //! a MPL metafunction class like the usual `Metafunction`s are. //! //! - When using `integral` with metafunctions returning //! `std::integral_constant`s, don't forget to include the //! boost/hana/ext/std/integral_constant.hpp header to ensure //! Hana can interoperate with the result. //! //! - In a SFINAE context, the expression `integral(f)(t...)` is valid //! whenever the expression `decltype(f(t...))::%type` is valid. //! //! //! Example //! ------- //! @include example/type/integral.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto integral = [](auto f) { return [](basic_type<T>...) { return decltype(f)::apply<T...>::type{}; }; }; #else template <typename F> struct integral_t; struct make_integral_t { template <typename F> constexpr integral_t<F> operator()(F const&) const { return {}; } }; constexpr make_integral_t integral{}; #endif //! Alias to `integral(metafunction<F>)`, provided for convenience. //! @ingroup group-Metafunction //! //! //! Example //! ------- //! @include example/type/trait.cpp template <template <typename ...> class F> constexpr auto trait = hana::integral(hana::metafunction<F>); BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_TYPE_HPP PK �|!\��h� � bool.hppnu �[��� /*! @file Includes boost/hana/fwd/integral_constant.hpp. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_BOOL_HPP #define BOOST_HANA_FWD_BOOL_HPP #include <boost/hana/fwd/integral_constant.hpp> #endif // !BOOST_HANA_FWD_BOOL_HPP PK �|!\�8��� � or.hppnu �[��� /*! @file Forward declares `boost::hana::or_`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_OR_HPP #define BOOST_HANA_FWD_OR_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Return whether any of the arguments is true-valued. //! @ingroup group-Logical //! //! `or_` can be called with one argument or more. When called with //! two arguments, `or_` uses tag-dispatching to find the right //! implementation. Otherwise, //! @code //! or_(x) == x //! or_(x, y, ...z) == or_(or_(x, y), z...) //! @endcode //! //! //! Example //! ------- //! @include example/or.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto or_ = [](auto&& x, auto&& ...y) -> decltype(auto) { return tag-dispatched; }; #else template <typename L, typename = void> struct or_impl : or_impl<L, when<true>> { }; struct or_t { template <typename X, typename Y> constexpr decltype(auto) operator()(X&& x, Y&& y) const; template <typename X, typename ...Y> constexpr decltype(auto) operator()(X&& x, Y&& ...y) const; }; constexpr or_t or_{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_OR_HPP PK �|!\��I permutations.hppnu �[��� /*! @file Forward declares `boost::hana::permutations`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_PERMUTATIONS_HPP #define BOOST_HANA_FWD_PERMUTATIONS_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Return a sequence of all the permutations of the given sequence. //! @ingroup group-Sequence //! //! Specifically, `permutations(xs)` is a sequence whose elements are //! permutations of the original sequence `xs`. The permutations are not //! guaranteed to be in any specific order. Also note that the number //! of permutations grows very rapidly as the length of the original //! sequence increases. The growth rate is `O(length(xs)!)`; with a //! sequence `xs` of length only 8, `permutations(xs)` contains over //! 40 000 elements! //! //! //! Example //! ------- //! @include example/permutations.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto permutations = [](auto&& xs) { return tag-dispatched; }; #else template <typename S, typename = void> struct permutations_impl : permutations_impl<S, when<true>> { }; struct permutations_t { template <typename Xs> constexpr auto operator()(Xs&& xs) const; }; constexpr permutations_t permutations{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_PERMUTATIONS_HPP PK �|!\> greater_equal.hppnu �[��� /*! @file Forward declares `boost::hana::greater_equal`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_GREATER_EQUAL_HPP #define BOOST_HANA_FWD_GREATER_EQUAL_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> #include <boost/hana/detail/nested_than_fwd.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns a `Logical` representing whether `x` is greater than or //! equal to `y`. //! @ingroup group-Orderable //! //! //! Signature //! --------- //! Given a Logical `Bool` and two Orderables `A` and `B` with a common //! embedding, the signature is //! @f$ \mathrm{greater\_equal} : A \times B \to Bool @f$. //! //! @param x, y //! Two objects to compare. //! //! //! Example //! ------- //! @include example/greater_equal.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto greater_equal = [](auto&& x, auto&& y) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename U, typename = void> struct greater_equal_impl : greater_equal_impl<T, U, when<true>> { }; struct greater_equal_t : detail::nested_than<greater_equal_t> { template <typename X, typename Y> constexpr decltype(auto) operator()(X&& x, Y&& y) const; }; constexpr greater_equal_t greater_equal{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_GREATER_EQUAL_HPP PK �|!\]��y� � all.hppnu �[��� /*! @file Forward declares `boost::hana::all`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ALL_HPP #define BOOST_HANA_FWD_ALL_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns whether all the keys of the structure are true-valued. //! @ingroup group-Searchable //! //! The keys of the structure must be `Logical`s. If the structure is not //! finite, a false-valued key must appear at a finite "index" in order //! for this method to finish. //! //! //! Example //! ------- //! @include example/all.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto all = [](auto&& xs) { return tag-dispatched; }; #else template <typename S, typename = void> struct all_impl : all_impl<S, when<true>> { }; struct all_t { template <typename Xs> constexpr auto operator()(Xs&& xs) const; }; constexpr all_t all{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ALL_HPP PK �|!\\g�� � greater.hppnu �[��� /*! @file Forward declares `boost::hana::greater`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_GREATER_HPP #define BOOST_HANA_FWD_GREATER_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> #include <boost/hana/detail/nested_than_fwd.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns a `Logical` representing whether `x` is greater than `y`. //! @ingroup group-Orderable //! //! //! Signature //! --------- //! Given a Logical `Bool` and two Orderables `A` and `B` with a common //! embedding, the signature is //! @f$ \mathrm{greater} : A \times B \to Bool @f$. //! //! @param x, y //! Two objects to compare. //! //! //! Example //! ------- //! @include example/greater.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto greater = [](auto&& x, auto&& y) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename U, typename = void> struct greater_impl : greater_impl<T, U, when<true>> { }; struct greater_t : detail::nested_than<greater_t> { template <typename X, typename Y> constexpr decltype(auto) operator()(X&& x, Y&& y) const; }; constexpr greater_t greater{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_GREATER_HPP PK �|!\�q3�� � extend.hppnu �[��� /*! @file Forward declares `boost::hana::extend`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_EXTEND_HPP #define BOOST_HANA_FWD_EXTEND_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Comonadic application of a function to a comonadic value. //! @ingroup group-Comonad //! //! Given a comonadic value and a function accepting a comonadic input, //! `extend` returns the result of applying the function to that input //! inside the comonadic context. //! //! //! Signature //! --------- //! Given a Comonad `W` and a function of type \f$ W(T) \to U \f$, the //! signature is //! \f$ //! \mathtt{extend} : W(T) \times (W(T) \to U) \to W(U) //! \f$ //! //! @param w //! A comonadic value to call the function with. //! //! @param f //! A function of signature \f$ W(T) \to U \f$ to be applied to its //! comonadic argument inside the comonadic context. //! //! //! Example //! ------- //! @include example/extend.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto extend = [](auto&& w, auto&& f) -> decltype(auto) { return tag-dispatched; }; #else template <typename W, typename = void> struct extend_impl : extend_impl<W, when<true>> { }; struct extend_t { template <typename W_, typename F> constexpr decltype(auto) operator()(W_&& w, F&& f) const; }; constexpr extend_t extend{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_EXTEND_HPP PK �|!\�T?� � all_of.hppnu �[��� /*! @file Forward declares `boost::hana::all_of`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ALL_OF_HPP #define BOOST_HANA_FWD_ALL_OF_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns whether all the keys of the structure satisfy the `predicate`. //! @ingroup group-Searchable //! //! If the structure is not finite, `predicate` has to return a false- //! valued `Logical` after looking at a finite number of keys for this //! method to finish. //! //! //! @param xs //! The structure to search. //! //! @param predicate //! A function called as `predicate(k)`, where `k` is a key of the //! structure, and returning a `Logical`. //! //! //! Example //! ------- //! @include example/all_of.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto all_of = [](auto&& xs, auto&& predicate) { return tag-dispatched; }; #else template <typename S, typename = void> struct all_of_impl : all_of_impl<S, when<true>> { }; struct all_of_t { template <typename Xs, typename Pred> constexpr auto operator()(Xs&& xs, Pred&& pred) const; }; constexpr all_of_t all_of{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ALL_OF_HPP PK �|!\'}-- - cartesian_product.hppnu �[��� /*! @file Forward declares `boost::hana::cartesian_product`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_CARTESIAN_PRODUCT_HPP #define BOOST_HANA_FWD_CARTESIAN_PRODUCT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Computes the cartesian product of a sequence of sequences. //! @ingroup group-Sequence //! //! Given a sequence of sequences, `cartesian_product` returns a new //! sequence of sequences containing the cartesian product of the //! original sequences. For this method to finish, a finite number //! of finite sequences must be provided. //! //! @note //! All the sequences must have the same tag, and that tag must also match //! that of the top-level sequence. //! //! //! Signature //! --------- //! Given a `Sequence` `S(T)`, the signature is //! \f[ //! \mathtt{cartesian\_product} : S(S(T)) \to S(S(T)) //! \f] //! //! @param xs //! A sequence of sequences of which the cartesian product is computed. //! //! //! Example //! ------- //! @include example/cartesian_product.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto cartesian_product = [](auto&& xs) { return tag-dispatched; }; #else template <typename S, typename = void> struct cartesian_product_impl : cartesian_product_impl<S, when<true>> { }; struct cartesian_product_t { template <typename Xs> constexpr auto operator()(Xs&& xs) const; }; constexpr cartesian_product_t cartesian_product{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_CARTESIAN_PRODUCT_HPP PK �|!\\��� � while.hppnu �[��� /*! @file Forward declares `boost::hana::while_`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_WHILE_HPP #define BOOST_HANA_FWD_WHILE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Apply a function to an initial state while some predicate is satisfied. //! @ingroup group-Logical //! //! This method is a natural extension of the `while` language construct //! to manipulate a state whose type may change from one iteration to //! another. However, note that having a state whose type changes from //! one iteration to the other is only possible as long as the predicate //! returns a `Logical` whose truth value is known at compile-time. //! //! Specifically, `while_(pred, state, f)` is equivalent to //! @code //! f(...f(f(state))) //! @endcode //! where `f` is iterated as long as `pred(f(...))` is a true-valued //! `Logical`. //! //! //! @param pred //! A predicate called on the state or on the result of applying `f` a //! certain number of times to the state, and returning whether `f` //! should be applied one more time. //! //! @param state //! The initial state on which `f` is applied. //! //! @param f //! A function that is iterated on the initial state. Note that the //! return type of `f` may change from one iteration to the other, //! but only while `pred` returns a compile-time `Logical`. In other //! words, `decltype(f(stateN))` may differ from `decltype(f(stateN+1))`, //! but only if `pred(f(stateN))` returns a compile-time `Logical`. //! //! //! Example //! ------- //! @include example/while.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto while_ = [](auto&& pred, auto&& state, auto&& f) -> decltype(auto) { return tag-dispatched; }; #else template <typename L, typename = void> struct while_impl : while_impl<L, when<true>> { }; struct while_t { template <typename Pred, typename State, typename F> constexpr decltype(auto) operator()(Pred&& pred, State&& state, F&& f) const; }; constexpr while_t while_{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_WHILE_HPP PK �|!\U�:j� � minimum.hppnu �[��� /*! @file Forward declares `boost::hana::minimum`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_MINIMUM_HPP #define BOOST_HANA_FWD_MINIMUM_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> #include <boost/hana/detail/nested_by_fwd.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Return the least element of a non-empty structure with respect to //! a `predicate`, by default `less`. //! @ingroup group-Foldable //! //! Given a non-empty structure and an optional binary predicate //! (`less` by default), `minimum` returns the least element of //! the structure, i.e. an element which is less than or equal to //! every other element in the structure, according to the predicate. //! //! If the structure contains heterogeneous objects, then the predicate //! must return a compile-time `Logical`. If no predicate is provided, //! the elements in the structure must be Orderable, or compile-time //! Orderable if the structure is heterogeneous. //! //! //! Signature //! --------- //! Given a `Foldable` `F`, a Logical `Bool` and a predicate //! \f$ \mathtt{pred} : T \times T \to Bool \f$, `minimum` has the //! following signatures. For the variant with a provided predicate, //! \f[ //! \mathtt{minimum} : F(T) \times (T \times T \to Bool) \to T //! \f] //! //! for the variant without a custom predicate, `T` is required to be //! Orderable. The signature is then //! \f[ //! \mathtt{minimum} : F(T) \to T //! \f] //! //! @param xs //! The structure to find the least element of. //! //! @param predicate //! A function called as `predicate(x, y)`, where `x` and `y` are elements //! of the structure. `predicate` should be a strict weak ordering on the //! elements of the structure and its return value should be a Logical, //! or a compile-time Logical if the structure is heterogeneous. //! //! ### Example //! @include example/minimum.cpp //! //! //! Syntactic sugar (`minimum.by`) //! ------------------------------ //! `minimum` can be called in a third way, which provides a nice syntax //! especially when working with the `ordering` combinator: //! @code //! minimum.by(predicate, xs) == minimum(xs, predicate) //! minimum.by(predicate) == minimum(-, predicate) //! @endcode //! //! where `minimum(-, predicate)` denotes the partial application of //! `minimum` to `predicate`. //! //! ### Example //! @include example/minimum_by.cpp //! //! //! Tag dispatching //! --------------- //! Both the non-predicated version and the predicated versions of //! `minimum` are tag-dispatched methods, and hence they can be //! customized independently. One reason for this is that some //! structures are able to provide a much more efficient implementation //! of `minimum` when the `less` predicate is used. Here is how the //! different versions of `minimum` are dispatched: //! @code //! minimum(xs) -> minimum_impl<tag of xs>::apply(xs) //! minimum(xs, pred) -> minimum_pred_impl<tag of xs>::apply(xs, pred) //! @endcode //! //! Also note that `minimum.by` is not tag-dispatched on its own, since it //! is just syntactic sugar for calling the corresponding `minimum`. #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto minimum = [](auto&& xs[, auto&& predicate]) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename = void> struct minimum_impl : minimum_impl<T, when<true>> { }; template <typename T, typename = void> struct minimum_pred_impl : minimum_pred_impl<T, when<true>> { }; struct minimum_t : detail::nested_by<minimum_t> { template <typename Xs> constexpr decltype(auto) operator()(Xs&& xs) const; template <typename Xs, typename Predicate> constexpr decltype(auto) operator()(Xs&& xs, Predicate&& pred) const; }; constexpr minimum_t minimum{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MINIMUM_HPP PK �|!\� �� � chain.hppnu �[��� /*! @file Forward declares `boost::hana::chain`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_CHAIN_HPP #define BOOST_HANA_FWD_CHAIN_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Feed a monadic value into a monadic computation. //! @ingroup group-Monad //! //! Given a monadic value and a monadic function, `chain` feeds the //! monadic value into the function, thus performing some Monad-specific //! effects, and returns the result. An implementation of `chain` must //! satisfy //! @code //! chain(xs, f) == flatten(transform(xs, f)) //! @endcode //! //! //! Signature //! --------- //! For a monad `M`, given a monadic value of type `M(A)` and a monadic //! function @f$ f : A \to M(B) @f$, `chain` has the signature //! @f$ //! \mathtt{chain} : M(A) \times (A \to M(B)) \to M(B) //! @f$. //! //! @param xs //! A monadic value to be fed to the function `f`. //! //! @param f //! A function taking a normal value in the `xs` structure, and returning //! a monadic value. This function is called as `f(x)`, where `x` is an //! element of the structure `xs`. //! //! //! Example //! ------- //! @include example/chain.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto chain = [](auto&& xs, auto&& f) -> decltype(auto) { return tag-dispatched; }; #else template <typename M, typename = void> struct chain_impl : chain_impl<M, when<true>> { }; struct chain_t { template <typename Xs, typename F> constexpr decltype(auto) operator()(Xs&& xs, F&& f) const; }; constexpr chain_t chain{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_CHAIN_HPP PK �|!\ �?� � remove.hppnu �[��� /*! @file Forward declares `boost::hana::remove`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_REMOVE_HPP #define BOOST_HANA_FWD_REMOVE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Remove all the elements of a monadic structure that are equal to some //! value. //! @ingroup group-MonadPlus //! //! Given a monadic structure `xs` and a `value`, `remove` returns a new //! monadic structure equal to `xs` without all its elements that are //! equal to the given `value`. `remove` is equivalent to `remove_if` //! with the `equal.to(value)` predicate, i.e. //! @code //! remove(xs, value) == remove_if(xs, equal.to(value)) //! @endcode //! //! //! Signature //! --------- //! Given a MonadPlus `M` and a value of type `T`, the signature is //! \f$ //! \mathrm{remove} : M(T) \times T \to M(T) //! \f$ //! //! @param xs //! A monadic structure to remove some elements from. //! //! @param value //! A value that is compared to every element `x` of the structure. //! Elements of the structure that are equal to that value are removed //! from the structure. This requires every element to be Comparable //! with `value`. Furthermore, in the current version of the library, //! comparing `value` with any element of the structure must yield a //! compile-time Logical. //! //! //! Example //! ------- //! @include example/remove.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto remove = [](auto&& xs, auto&& value) { return tag-dispatched; }; #else template <typename M, typename = void> struct remove_impl : remove_impl<M, when<true>> { }; struct remove_t { template <typename Xs, typename Value> constexpr auto operator()(Xs&& xs, Value&& value) const; }; constexpr remove_t remove{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_REMOVE_HPP PK �|!\���0� � partition.hppnu �[��� /*! @file Forward declares `boost::hana::partition`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_PARTITION_HPP #define BOOST_HANA_FWD_PARTITION_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> #include <boost/hana/detail/nested_by_fwd.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Partition a sequence based on a `predicate`. //! @ingroup group-Sequence //! //! Specifically, returns an unspecified `Product` whose first element is //! a sequence of the elements satisfying the predicate, and whose second //! element is a sequence of the elements that do not satisfy the predicate. //! //! //! Signature //! --------- //! Given a Sequence `S(T)`, an `IntegralConstant` `Bool` holding a value //! of type `bool`, and a predicate \f$ T \to Bool \f$, `partition` has //! the following signature: //! \f[ //! \mathtt{partition} : S(T) \times (T \to Bool) \to S(T) \times S(T) //! \f] //! //! @param xs //! The sequence to be partitioned. //! //! @param predicate //! A function called as `predicate(x)` for each element `x` in the //! sequence, and returning whether `x` should be added to the sequence //! in the first component or in the second component of the resulting //! pair. In the current version of the library, `predicate` must return //! an `IntegralConstant` holding a value convertible to `bool`. //! //! //! Syntactic sugar (`partition.by`) //! -------------------------------- //! `partition` can be called in an alternate way, which provides a nice //! syntax in some cases where the predicate is short: //! @code //! partition.by(predicate, xs) == partition(xs, predicate) //! partition.by(predicate) == partition(-, predicate) //! @endcode //! //! where `partition(-, predicate)` denotes the partial application of //! `partition` to `predicate`. //! //! //! Example //! ------- //! @include example/partition.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto partition = [](auto&& xs, auto&& predicate) { return tag-dispatched; }; #else template <typename S, typename = void> struct partition_impl : partition_impl<S, when<true>> { }; struct partition_t : detail::nested_by<partition_t> { template <typename Xs, typename Pred> constexpr auto operator()(Xs&& xs, Pred&& pred) const; }; constexpr partition_t partition{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_PARTITION_HPP PK �|!\�d�** ** string.hppnu �[��� /*! @file Forward declares `boost::hana::string`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_STRING_HPP #define BOOST_HANA_FWD_STRING_HPP #include <boost/hana/config.hpp> #include <boost/hana/fwd/core/make.hpp> #include <boost/hana/fwd/core/to.hpp> BOOST_HANA_NAMESPACE_BEGIN #ifdef BOOST_HANA_DOXYGEN_INVOKED //! @ingroup group-datatypes //! Compile-time string. //! //! Conceptually, a `hana::string` is like a tuple holding //! `integral_constant`s of underlying type `char`. However, the //! interface of `hana::string` is not as rich as that of a tuple, //! because a string can only hold compile-time characters as opposed //! to any kind of object. //! //! Compile-time strings are used for simple purposes like being keys in a //! `hana::map` or tagging the members of a `Struct`. However, you might //! find that `hana::string` does not provide enough functionality to be //! used as a full-blown compile-time string implementation (e.g. regexp //! matching or substring finding). Indeed, providing a comprehensive //! string interface is a lot of job, and it is out of the scope of the //! library for the time being. //! //! //! @note //! The representation of `hana::string` is implementation-defined. //! In particular, one should not take for granted that the template //! parameters are `char`s. The proper way to access the contents of //! a `hana::string` as character constants is to use `hana::unpack`, //! `.c_str()` or `hana::to<char const*>`, as documented below. More //! details [in the tutorial](@ref tutorial-containers-types). //! //! //! Modeled concepts //! ---------------- //! For most purposes, a `hana::string` is functionally equivalent to a //! tuple holding `Constant`s of underlying type `char`. //! //! 1. `Comparable`\n //! Two strings are equal if and only if they have the same number of //! characters and characters at corresponding indices are equal. //! @include example/string/comparable.cpp //! //! 2. `Orderable`\n //! The total order implemented for `Orderable` is the usual //! lexicographical comparison of strings. //! @include example/string/orderable.cpp //! //! 3. `Monoid`\n //! Strings form a monoid under concatenation, with the neutral element //! being the empty string. //! @include example/string/monoid.cpp //! //! 4. `Foldable`\n //! Folding a string is equivalent to folding the sequence of its //! characters. //! @include example/string/foldable.cpp //! //! 5. `Iterable`\n //! Iterating over a string is equivalent to iterating over the sequence //! of its characters. Also note that `operator[]` can be used instead of //! the `at` function. //! @include example/string/iterable.cpp //! //! 6. `Searchable`\n //! Searching through a string is equivalent to searching through the //! sequence of its characters. //! @include example/string/searchable.cpp //! //! 7. `Hashable`\n //! The hash of a compile-time string is a type uniquely representing //! that string. //! @include example/string/hashable.cpp //! //! //! Conversion to `char const*` //! --------------------------- //! A `hana::string` can be converted to a `constexpr` null-delimited //! string of type `char const*` by using the `c_str()` method or //! `hana::to<char const*>`. This makes it easy to turn a compile-time //! string into a runtime string. However, note that this conversion is //! not an embedding, because `char const*` does not model the same //! concepts as `hana::string` does. //! @include example/string/to.cpp //! //! Conversion from any Constant holding a `char const*` //! ---------------------------------------------------- //! A `hana::string` can be created from any `Constant` whose underlying //! value is convertible to a `char const*` by using `hana::to`. The //! contents of the `char const*` are used to build the content of the //! `hana::string`. //! @include example/string/from_c_str.cpp //! //! Rationale for `hana::string` not being a `Constant` itself //! ---------------------------------------------------------- //! The underlying type held by a `hana::string` could be either `char const*` //! or some other constexpr-enabled string-like container. In the first case, //! `hana::string` can not be a `Constant` because the models of several //! concepts would not be respected by the underlying type, causing `value` //! not to be structure-preserving. Providing an underlying value of //! constexpr-enabled string-like container type like `std::string_view` //! would be great, but that's a bit complicated for the time being. template <typename implementation_defined> struct string { // Default-construct a `hana::string`; no-op since `hana::string` is stateless. constexpr string() = default; // Copy-construct a `hana::string`; no-op since `hana::string` is stateless. constexpr string(string const&) = default; //! Equivalent to `hana::equal` template <typename X, typename Y> friend constexpr auto operator==(X&& x, Y&& y); //! Equivalent to `hana::not_equal` template <typename X, typename Y> friend constexpr auto operator!=(X&& x, Y&& y); //! Equivalent to `hana::less` template <typename X, typename Y> friend constexpr auto operator<(X&& x, Y&& y); //! Equivalent to `hana::greater` template <typename X, typename Y> friend constexpr auto operator>(X&& x, Y&& y); //! Equivalent to `hana::less_equal` template <typename X, typename Y> friend constexpr auto operator<=(X&& x, Y&& y); //! Equivalent to `hana::greater_equal` template <typename X, typename Y> friend constexpr auto operator>=(X&& x, Y&& y); //! Performs concatenation; equivalent to `hana::plus` template <typename X, typename Y> friend constexpr auto operator+(X&& x, Y&& y); //! Equivalent to `hana::at` template <typename N> constexpr decltype(auto) operator[](N&& n); //! Returns a null-delimited C-style string. static constexpr char const* c_str(); }; #else template <char ...s> struct string; #endif //! Tag representing a compile-time string. //! @relates hana::string struct string_tag { }; #ifdef BOOST_HANA_DOXYGEN_INVOKED //! Create a compile-time `hana::string` from a parameter pack of `char` //! `integral_constant`s. //! @relates hana::string //! //! Given zero or more `integral_constant`s of underlying type `char`, //! `make<string_tag>` creates a `hana::string` containing those characters. //! This is provided mostly for consistency with the rest of the library, //! as `hana::string_c` is more convenient to use in most cases. //! //! //! Example //! ------- //! @include example/string/make.cpp template <> constexpr auto make<string_tag> = [](auto&& ...chars) { return string<implementation_defined>{}; }; #endif //! Alias to `make<string_tag>`; provided for convenience. //! @relates hana::string constexpr auto make_string = make<string_tag>; //! Equivalent to `to<string_tag>`; provided for convenience. //! @relates hana::string constexpr auto to_string = to<string_tag>; //! Create a compile-time string from a parameter pack of characters. //! @relates hana::string //! //! //! Example //! ------- //! @include example/string/string_c.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <char ...s> constexpr string<implementation_defined> string_c{}; #else template <char ...s> constexpr string<s...> string_c{}; #endif //! Create a compile-time string from a string literal. //! @relates hana::string //! //! This macro is a more convenient alternative to `string_c` for creating //! compile-time strings. However, since this macro uses a lambda //! internally, it can't be used in an unevaluated context, or where //! a constant expression is expected before C++17. //! //! //! Example //! ------- //! @include example/string/macro.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED auto BOOST_HANA_STRING(s) = see documentation; #define BOOST_HANA_STRING(s) see documentation // Note: // The trick above seems to exploit a bug in Doxygen, which makes the // BOOST_HANA_STRING macro appear in the related objects of hana::string // (as we want it to). #else // defined in <boost/hana/string.hpp> #endif #ifdef BOOST_HANA_CONFIG_ENABLE_STRING_UDL namespace literals { //! Creates a compile-time string from a string literal. //! @relatesalso boost::hana::string //! //! The string literal is parsed at compile-time and the result is //! returned as a `hana::string`. This feature is an extension that //! is disabled by default; see below for details. //! //! @note //! Only narrow string literals are supported right now; support for //! fancier types of string literals like wide or UTF-XX might be //! added in the future if there is a demand for it. See [this issue] //! [Hana.issue80] if you need this. //! //! @warning //! This user-defined literal is an extension which requires a special //! string literal operator that is not part of the standard yet. //! That operator is supported by both Clang and GCC, and several //! proposals were made for it to enter C++17. However, since it is //! not standard, it is disabled by default and defining the //! `BOOST_HANA_CONFIG_ENABLE_STRING_UDL` config macro is required //! to get this operator. Hence, if you want to stay safe, just use //! the `BOOST_HANA_STRING` macro instead. If you want to be fast and //! furious (I do), define `BOOST_HANA_CONFIG_ENABLE_STRING_UDL`. //! //! //! Example //! ------- //! @include example/string/literal.cpp //! //! [Hana.issue80]: https://github.com/boostorg/hana/issues/80 template <typename CharT, CharT ...s> constexpr auto operator"" _s(); } #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_STRING_HPP PK �|!\R���� � find.hppnu �[��� /*! @file Forward declares `boost::hana::find`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FIND_HPP #define BOOST_HANA_FWD_FIND_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Finds the value associated to the given key in a structure. //! @ingroup group-Searchable //! //! Given a `key` and a `Searchable` structure, `find` returns the `just` //! the first value whose key is equal to the given `key`, or `nothing` if //! there is no such key. Comparison is done with `equal`. `find` satisfies //! the following: //! @code //! find(xs, key) == find_if(xs, equal.to(key)) //! @endcode //! //! //! @param xs //! The structure to be searched. //! //! @param key //! A key to be searched for in the structure. The key has to be //! `Comparable` with the other keys of the structure. In the current //! version of the library, the comparison of `key` with any other key //! of the structure must return a compile-time `Logical`. //! //! //! Example //! ------- //! @include example/find.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto find = [](auto&& xs, auto const& key) { return tag-dispatched; }; #else template <typename S, typename = void> struct find_impl : find_impl<S, when<true>> { }; struct find_t { template <typename Xs, typename Key> constexpr auto operator()(Xs&& xs, Key const& key) const; }; constexpr find_t find{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FIND_HPP PK �|!\��i�~ ~ max.hppnu �[��� /*! @file Forward declares `boost::hana::max`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_MAX_HPP #define BOOST_HANA_FWD_MAX_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns the greatest of its arguments according to the `less` ordering. //! @ingroup group-Orderable //! //! //! @todo Can't specify the signature here either. See `min` for details. //! //! Example //! ------- //! @include example/max.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto max = [](auto&& x, auto&& y) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename U, typename = void> struct max_impl : max_impl<T, U, when<true>> { }; struct max_t { template <typename X, typename Y> constexpr decltype(auto) operator()(X&& x, Y&& y) const; }; constexpr max_t max{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MAX_HPP PK �|!\]�eW W value.hppnu �[��� /*! @file Forward declares `boost::hana::value`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_VALUE_HPP #define BOOST_HANA_FWD_VALUE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Return the compile-time value associated to a constant. //! @ingroup group-Constant //! //! This function returns the value associated to a `Constant`. That //! value is always a constant expression. The normal way of using //! `value` on an object `c` is //! @code //! constexpr auto result = hana::value<decltype(c)>(); //! @endcode //! //! However, for convenience, an overload of `value` is provided so that //! it can be called as: //! @code //! constexpr auto result = hana::value(c); //! @endcode //! //! This overload works by taking a `const&` to its argument, and then //! forwarding to the first version of `value`. Since it does not use //! its argument, the result can still be a constant expression, even //! if the argument is not a constant expression. //! //! @note //! `value<T>()` is tag-dispatched as `value_impl<C>::%apply<T>()`, where //! `C` is the tag of `T`. //! //! @note //! `hana::value` is an overloaded function, not a function object. //! Hence, it can't be passed to higher-order algorithms. If you need //! an equivalent function object, use `hana::value_of` instead. //! //! //! Example //! ------- //! @include example/value.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename T> constexpr auto value = []() -> decltype(auto) { return tag-dispatched; }; #else template <typename C, typename = void> struct value_impl : value_impl<C, when<true>> { }; template <typename T> constexpr decltype(auto) value(); template <typename T> constexpr decltype(auto) value(T const&) { return hana::value<T>(); } #endif //! Equivalent to `value`, but can be passed to higher-order algorithms. //! @ingroup group-Constant //! //! This function object is equivalent to `value`, except it can be passed //! to higher order algorithms because it is a function object. `value` //! can't be passed to higher-order algorithms because it is implemented //! as an overloaded function. //! //! @note //! This function is a simple alias to `value`, and hence it is not //! tag-dispatched and can't be customized. //! //! //! Example //! ------- //! @include example/value_of.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto value_of = [](auto const& c) -> decltype(auto) { return hana::value(c); }; #else struct value_of_t { template <typename T> constexpr decltype(auto) operator()(T const&) const { return hana::value<T>(); } }; constexpr value_of_t value_of{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_VALUE_HPP PK �|!\�X� � mult.hppnu �[��� /*! @file Forward declares `boost::hana::mult`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_MULT_HPP #define BOOST_HANA_FWD_MULT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Associative operation of a `Ring`. //! @ingroup group-Ring //! //! @param x, y //! Two `Ring` elements to combine with the `Ring` binary operation. //! //! //! Cross-type version of the method //! -------------------------------- //! The `mult` method is "overloaded" to handle distinct data types //! with certain properties. Specifically, `mult` is defined for //! _distinct_ data types `A` and `B` such that //! 1. `A` and `B` share a common data type `C`, as determined by the //! `common` metafunction //! 2. `A`, `B` and `C` are all `Ring`s when taken individually //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Ring`-embeddings, as //! determined by the `is_embedding` metafunction. //! //! The definition of `mult` for data types satisfying the above //! properties is obtained by setting //! @code //! mult(x, y) = mult(to<C>(x), to<C>(y)) //! @endcode //! //! //! Example //! ------- //! @include example/mult.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto mult = [](auto&& x, auto&& y) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename U, typename = void> struct mult_impl : mult_impl<T, U, when<true>> { }; struct mult_t { template <typename X, typename Y> constexpr decltype(auto) operator()(X&& x, Y&& y) const; }; constexpr mult_t mult{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MULT_HPP PK �|!\&�?� � insert.hppnu �[��� /*! @file Forward declares `boost::hana::insert`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_INSERT_HPP #define BOOST_HANA_FWD_INSERT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN // Note: This function is documented per datatype/concept only. //! @cond template <typename T, typename = void> struct insert_impl : insert_impl<T, when<true>> { }; //! @endcond struct insert_t { template <typename Set, typename ...Args> constexpr decltype(auto) operator()(Set&& set, Args&& ...args) const; }; constexpr insert_t insert{}; //! Insert a value at a given index in a sequence. //! @ingroup group-Sequence //! //! Given a sequence, an index and an element to insert, `insert` inserts //! the element at the given index. //! //! @param xs //! The sequence in which a value should be inserted. //! //! @param n //! The index at which an element should be inserted. This must be a //! non-negative `Constant` of an integral type, and it must also be //! true that `n < length(xs)` if `xs` is a finite sequence. //! //! @param element //! The element to insert in the sequence. //! //! //! Example //! ------- //! @include example/insert.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto insert = [](auto&& xs, auto&& n, auto&& element) { return tag-dispatched; }; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_INSERT_HPP PK �|!\�(pN N monadic_fold_right.hppnu �[��� /*! @file Forward declares `boost::hana::monadic_fold_right`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_MONADIC_FOLD_RIGHT_HPP #define BOOST_HANA_FWD_MONADIC_FOLD_RIGHT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Monadic right-fold of a structure with a binary operation and an //! optional initial reduction state. //! @ingroup group-Foldable //! //! @note //! This assumes the reader to be accustomed to non-monadic right-folds as //! explained by `hana::fold_right`, and to have read the [primer] //! (@ref monadic-folds) on monadic folds. //! //! `monadic_fold_right<M>` is a right-associative monadic fold. Given a //! structure containing `x1, ..., xn`, a function `f` and an optional //! initial state, `monadic_fold_right<M>` applies `f` as follows //! @code //! // with state //! (f(x1, -) | (f(x2, -) | (f(x3, -) | (... | f(xn, state))))) //! //! // without state //! (f(x1, -) | (f(x2, -) | (f(x3, -) | (... | f(xn-1, xn))))) //! @endcode //! //! where `f(xk, -)` denotes the partial application of `f` to `xk`, //! and `|` is just the operator version of the monadic `chain`. //! It is worth noting that the order in which the binary function should //! expect its arguments is reversed from `monadic_fold_left<M>`. //! //! When the structure is empty, one of two things may happen. If an //! initial state was provided, it is lifted to the given Monad and //! returned as-is. Otherwise, if the no-state version of the function //! was used, an error is triggered. When the stucture contains a single //! element and the no-state version of the function was used, that //! single element is lifted into the given Monad and returned as is. //! //! //! Signature //! --------- //! Given a `Monad` `M`, a `Foldable` `F`, an initial state of tag `S`, //! and a function @f$ f : T \times S \to M(S) @f$, the signatures of //! `monadic_fold_right<M>` are //! \f[ //! \mathtt{monadic\_fold\_right}_M : //! F(T) \times S \times (T \times S \to M(S)) \to M(S) //! \f] //! //! for the version with an initial state, and //! \f[ //! \mathtt{monadic\_fold\_right}_M : //! F(T) \times (T \times T \to M(T)) \to M(T) //! \f] //! //! for the version without an initial state. //! //! @tparam M //! The Monad representing the monadic context in which the fold happens. //! The return type of `f` must be in that Monad. //! //! @param xs //! The structure to fold. //! //! @param state //! The initial value used for folding. If the structure is empty, this //! value is lifted in to the `M` Monad and then returned as-is. //! //! @param f //! A binary function called as `f(x, state)`, where `state` is the result //! accumulated so far and `x` is an element in the structure. The //! function must return its result inside the `M` Monad. //! //! //! Example //! ------- //! @include example/monadic_fold_right.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename M> constexpr auto monadic_fold_right = [](auto&& xs[, auto&& state], auto&& f) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename = void> struct monadic_fold_right_impl : monadic_fold_right_impl<T, when<true>> { }; template <typename M> struct monadic_fold_right_t { template <typename Xs, typename State, typename F> constexpr decltype(auto) operator()(Xs&& xs, State&& state, F&& f) const; template <typename Xs, typename F> constexpr decltype(auto) operator()(Xs&& xs, F&& f) const; }; template <typename M> constexpr monadic_fold_right_t<M> monadic_fold_right{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MONADIC_FOLD_RIGHT_HPP PK �|!\�2 2 replace.hppnu �[��� /*! @file Forward declares `boost::hana::replace`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_REPLACE_HPP #define BOOST_HANA_FWD_REPLACE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Replace all the elements of a structure that compare equal //! to some `value` with some new fixed value. //! @ingroup group-Functor //! //! //! Signature //! --------- //! Given `F` a Functor and `U` a type that can be compared with `T`, //! the signature is //! \f$ //! \mathtt{replace} : F(T) \times U \times T \to F(T) //! \f$ //! //! @param xs //! The structure to replace elements of. //! //! @param oldval //! An object compared with each element of the structure. Elements //! of the structure that compare equal to `oldval` are replaced //! by `newval` in the new structure. //! //! @param newval //! A value by which every element `x` of the structure that compares //! equal to `oldval` is replaced. //! //! //! Example //! ------- //! @include example/replace.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto replace = [](auto&& xs, auto&& oldval, auto&& newval) { return tag-dispatched; }; #else template <typename Xs, typename = void> struct replace_impl : replace_impl<Xs, when<true>> { }; struct replace_t { template <typename Xs, typename OldVal, typename NewVal> constexpr auto operator()(Xs&& xs, OldVal&& oldval, NewVal&& newval) const; }; constexpr replace_t replace{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_REPLACE_HPP PK �|!\�?t}( ( filter.hppnu �[��� /*! @file Forward declares `boost::hana::filter`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FILTER_HPP #define BOOST_HANA_FWD_FILTER_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Filter a monadic structure using a custom predicate. //! @ingroup group-MonadPlus //! //! Given a monadic structure and a predicate, `filter` returns a new //! monadic structure containing only those elements that satisfy the //! predicate. This is a generalization of the usual `filter` function //! for sequences; it works for any MonadPlus. Intuitively, `filter` is //! somewhat equivalent to: //! @code //! filter(xs, pred) == flatten(transform(xs, [](auto x) { //! return pred(x) ? lift<Xs>(x) : empty<Xs>(); //! }) //! @endcode //! In other words, we basically turn a monadic structure containing //! `[x1, ..., xn]` into a monadic structure containing //! @code //! [ //! pred(x1) ? [x1] : [], //! pred(x2) ? [x2] : [], //! ... //! pred(xn) ? [xn] : [] //! ] //! @endcode //! and we then `flatten` that. //! //! //! Signature //! --------- //! Given a `MonadPlus` `M` and an `IntegralConstant` `Bool` holding a //! value of type `bool`, the signature is //! @f$ \mathtt{filter} : M(T) \times (T \to \mathtt{Bool}) \to M(T) @f$. //! //! @param xs //! The monadic structure to filter. //! //! @param pred //! A function called as `pred(x)` for each element `x` in the monadic //! structure and returning whether that element should be __kept__ in //! the resulting structure. In the current version of the library, the //! predicate has to return an `IntegralConstant` holding a value //! convertible to a `bool`. //! //! //! Example //! ------- //! @include example/filter.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto filter = [](auto&& xs, auto&& pred) { return tag-dispatched; }; #else template <typename M, typename = void> struct filter_impl : filter_impl<M, when<true>> { }; struct filter_t { template <typename Xs, typename Pred> constexpr auto operator()(Xs&& xs, Pred&& pred) const; }; constexpr filter_t filter{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FILTER_HPP PK �|!\U�)t. . define_struct.hppnu �[��� /*! @file Documents the `BOOST_HANA_DEFINE_STRUCT` macro. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_DEFINE_STRUCT_HPP #define BOOST_HANA_FWD_DEFINE_STRUCT_HPP #include <boost/hana/config.hpp> BOOST_HANA_NAMESPACE_BEGIN // Note: // The weird definition as a variable seems to exploit a glitch in Doxygen // which makes the macro appear in the related objects of Struct (as we // want it to). //! Defines members of a structure, while at the same time //! modeling `Struct`. //! @ingroup group-Struct //! //! Using this macro in the body of a user-defined type will define the //! given members inside that type, and will also provide a model of the //! `Struct` concept for that user-defined type. This macro is often the //! easiest way to define a model of the `Struct` concept. //! //! @note //! This macro only works if the tag of the user-defined type `T` is `T` //! itself. This is the case unless you specifically asked for something //! different; see `tag_of`'s documentation. //! //! //! Example //! ------- //! @include example/define_struct.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED auto BOOST_HANA_DEFINE_STRUCT(...) = ; #define BOOST_HANA_DEFINE_STRUCT(Name, ...) see documentation #else // defined in <boost/hana/define_struct.hpp> #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_DEFINE_STRUCT_HPP PK �|!\@��� � negate.hppnu �[��� /*! @file Forward declares `boost::hana::negate`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_NEGATE_HPP #define BOOST_HANA_FWD_NEGATE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Return the inverse of an element of a group. //! @ingroup group-Group //! //! //! Example //! ------- //! @include example/negate.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto negate = [](auto&& x) -> decltype(auto) { return tag-dispatched; }; #else template <typename G, typename = void> struct negate_impl : negate_impl<G, when<true>> { }; struct negate_t { template <typename X> constexpr decltype(auto) operator()(X&& x) const; }; constexpr negate_t negate{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_NEGATE_HPP PK �|!\��H�* * fold.hppnu �[��� /*! @file Forward declares `boost::hana::fold`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FOLD_HPP #define BOOST_HANA_FWD_FOLD_HPP #include <boost/hana/config.hpp> #include <boost/hana/fwd/fold_left.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Equivalent to `fold_left`; provided for convenience. //! @ingroup group-Foldable //! //! `fold` is equivalent to `fold_left`. However, it is not tag-dispatched //! on its own because it is just an alias to `fold_left`. Also note that //! `fold` can be called with or without an initial state, just like //! `fold_left`: //! //! @code //! fold(xs, state, f) == fold_left(xs, state, f) //! fold(xs, f) == fold_left(xs, f) //! @endcode //! //! //! Example //! ------- //! @include example/fold.cpp constexpr auto fold = fold_left; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FOLD_HPP PK �|!\D*�� � slice.hppnu �[��� /*! @file Forward declares `boost::hana::slice` and `boost::hana::slice_c`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_SLICE_HPP #define BOOST_HANA_FWD_SLICE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> #include <cstddef> BOOST_HANA_NAMESPACE_BEGIN //! Extract the elements of a `Sequence` at the given indices. //! @ingroup group-Sequence //! //! Given an arbitrary sequence of `indices`, `slice` returns a new //! sequence of the elements of the original sequence that appear at //! those indices. In other words, //! @code //! slice([x1, ..., xn], [i1, ..., ik]) == [x_i1, ..., x_ik] //! @endcode //! //! The indices do not have to be ordered or contiguous in any particular //! way, but they must not be out of the bounds of the sequence. It is //! also possible to specify the same index multiple times, in which case //! the element at this index will be repeatedly included in the resulting //! sequence. //! //! //! @param xs //! The sequence from which a subsequence is extracted. //! //! @param indices //! A compile-time `Foldable` containing non-negative `IntegralConstant`s //! representing the indices. The indices are 0-based, and they must all //! be in bounds of the `xs` sequence. Note that any `Foldable` will //! really do (no need for an `Iterable`, for example); the linearization //! of the `indices` is used to determine the order of the elements //! included in the slice. //! //! //! Example //! ------- //! @include example/slice.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto slice = [](auto&& xs, auto&& indices) { return tag-dispatched; }; #else template <typename S, typename = void> struct slice_impl : slice_impl<S, when<true>> { }; struct slice_t { template <typename Xs, typename Indices> constexpr auto operator()(Xs&& xs, Indices&& indices) const; }; constexpr slice_t slice{}; #endif //! Shorthand to `slice` a contiguous range of elements. //! @ingroup group-Sequence //! //! `slice_c` is simply a shorthand to slice a contiguous range of //! elements. In particular, `slice_c<from, to>(xs)` is equivalent to //! `slice(xs, range_c<std::size_t, from, to>)`, which simply slices //! all the elements of `xs` contained in the half-open interval //! delimited by `[from, to)`. Like for `slice`, the indices used with //! `slice_c` are 0-based and they must be in the bounds of the sequence //! being sliced. //! //! //! @tparam from //! The index of the first element in the slice. //! //! @tparam to //! One-past the index of the last element in the slice. It must hold //! that `from <= to`. //! //! //! Example //! ------- //! @include example/slice_c.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <std::size_t from, std::size_t to> constexpr auto slice_c = [](auto&& xs) { return hana::slice(forwarded(xs), hana::range_c<std::size_t, from, to>); }; #else template <std::size_t from, std::size_t to> struct slice_c_t; template <std::size_t from, std::size_t to> constexpr slice_c_t<from, to> slice_c{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_SLICE_HPP PK �|!\��}#� � monadic_compose.hppnu �[��� /*! @file Forward declares `boost::hana::monadic_compose`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_MONADIC_COMPOSE_HPP #define BOOST_HANA_FWD_MONADIC_COMPOSE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Composition of monadic functions. //! @ingroup group-Monad //! //! Given two monadic functions `f` and `g`, `monadic_compose` returns //! a new function equivalent to the composition of `f` with `g`, except //! the result of `g` is `chain`ed into `f` instead of simply passed to //! it, as with normal composition. `monadic_compose` satisfies //! @code //! monadic_compose(f, g)(x) == chain(g(x), f) //! @endcode //! //! //! @note //! Unlike `compose`, `monadic_compose` does not generalize nicely to //! arities higher than one. Hence, only unary functions may be used //! with `monadic_compose`. //! //! //! Signature //! --------- //! Given a `Monad` `M` and two functions @f$ f : B \to M(C) @f$ and //! @f$ g : A \to M(B) @f$, the signature is //! @f$ //! \mathtt{monadic\_compose} //! : (B \to M(C)) \times (A \to M(B)) \to (A \to M(C)) //! @f$. //! //! @param f //! A monadic function with signature @f$ B \to M(C) @f$. //! //! @param g //! A monadic function with signature @f$ A \to M(B) @f$. //! //! //! @note //! This method is not tag-dispatched, so it can't be customized directly. //! //! //! Example //! ------- //! @include example/monadic_compose.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto monadic_compose = [](auto&& f, auto&& g) { return [perfect-capture](auto&& x) -> decltype(auto) { return hana::chain(forwarded(g)(forwarded(x)), forwarded(f)); }; }; #else struct monadic_compose_t { template <typename F, typename G> constexpr auto operator()(F&& f, G&& g) const; }; constexpr monadic_compose_t monadic_compose{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MONADIC_COMPOSE_HPP PK �|!\?��j� � mod.hppnu �[��� /*! @file Forward declares `boost::hana::mod`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_MOD_HPP #define BOOST_HANA_FWD_MOD_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Generalized integer modulus. //! @ingroup group-EuclideanRing //! //! Given two elements of an EuclideanRing `x` and `y`, with `y` //! nonzero, `mod` returns the modulus of the division of `x` by `y`. //! In other words, `mod` can be seen as an equivalent to `%`. //! //! Cross-type version of the method //! -------------------------------- //! The `mod` method is "overloaded" to handle distinct data types //! with certain properties. Specifically, `mod` is defined for //! _distinct_ data types `A` and `B` such that //! 1. `A` and `B` share a common data type `C`, as determined by the //! `common` metafunction //! 2. `A`, `B` and `C` are all `EuclideanRing`s when taken individually //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Ring`-embeddings, as //! determined by the `is_embedding` metafunction. //! //! In that case, `mod` is defined as //! @code //! mod(x, y) = mod(to<C>(x), to<C>(y)) //! @endcode //! //! //! Example //! ------- //! @include example/mod.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto mod = [](auto&& x, auto&& y) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename U, typename = void> struct mod_impl : mod_impl<T, U, when<true>> { }; struct mod_t { template <typename X, typename Y> constexpr decltype(auto) operator()(X&& x, Y&& y) const; }; constexpr mod_t mod{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MOD_HPP PK �|!\˗!#s s if.hppnu �[��� /*! @file Forward declares `boost::hana::if_`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_IF_HPP #define BOOST_HANA_FWD_IF_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Conditionally return one of two values based on a condition. //! @ingroup group-Logical //! //! Specifically, `then` is returned iff `cond` is true-valued, and //! `else_` is returned otherwise. Note that some `Logical` models may //! allow `then` and `else_` to have different types, while others may //! require both values to have the same type. //! //! //! @param cond //! The condition determining which of the two values is returned. //! //! @param then //! The value returned when `cond` is true-valued. //! //! @param else_ //! The value returned when `cond` is false-valued. //! //! //! Example //! ------- //! @include example/if.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto if_ = [](auto&& cond, auto&& then, auto&& else_) -> decltype(auto) { return tag-dispatched; }; #else template <typename L, typename = void> struct if_impl : if_impl<L, when<true>> { }; struct if_t { template <typename Cond, typename Then, typename Else> constexpr decltype(auto) operator()(Cond&& cond, Then&& then, Else&& else_) const; }; constexpr if_t if_{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_IF_HPP PK �|!\��h�s s zip_shortest_with.hppnu �[��� /*! @file Forward declares `boost::hana::zip_shortest_with`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ZIP_SHORTEST_WITH_HPP #define BOOST_HANA_FWD_ZIP_SHORTEST_WITH_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Zip one sequence or more with a given function. //! @ingroup group-Sequence //! //! Given a `n`-ary function `f` and `n` sequences `s1, ..., sn`, //! `zip_shortest_with` produces a sequence whose `i`-th element is //! `f(s1[i], ..., sn[i])`, where `sk[i]` denotes the `i`-th element of //! the `k`-th sequence. In other words, `zip_shortest_with` produces a //! sequence of the form //! @code //! [ //! f(s1[0], ..., sn[0]), //! f(s1[1], ..., sn[1]), //! ... //! f(s1[M], ..., sn[M]) //! ] //! @endcode //! where `M` is the length of the shortest sequence. Hence, the returned //! sequence stops when the shortest input sequence is exhausted. If you //! know that all the sequences you are about to zip have the same length, //! you should use `zip_with` instead, since it can be more optimized. //! Also note that it is an error to provide no sequence at all, i.e. //! `zip_shortest_with` expects at least one sequence. //! //! //! Example //! ------- //! @include example/zip_shortest_with.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto zip_shortest_with = [](auto&& f, auto&& x1, ..., auto&& xn) { return tag-dispatched; }; #else template <typename S, typename = void> struct zip_shortest_with_impl : zip_shortest_with_impl<S, when<true>> { }; struct zip_shortest_with_t { template <typename F, typename Xs, typename ...Ys> constexpr auto operator()(F&& f, Xs&& xs, Ys&& ...ys) const; }; constexpr zip_shortest_with_t zip_shortest_with{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ZIP_SHORTEST_WITH_HPP PK �|!\tVz�� � size.hppnu �[��� /*! @file Forward declares `boost::hana::size`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_SIZE_HPP #define BOOST_HANA_FWD_SIZE_HPP #include <boost/hana/config.hpp> #include <boost/hana/fwd/length.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Equivalent to `length`; provided for consistency with the //! standard library. //! @ingroup group-Foldable //! //! This method is an alias to `length` provided for convenience and //! consistency with the standard library. As an alias, `size` is not //! tag-dispatched on its own and `length` should be customized instead. //! //! //! Example //! ------- //! @include example/size.cpp constexpr auto size = hana::length; BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_SIZE_HPP PK �|!\+A�gC C remove_at.hppnu �[��� /*! @file Forward declares `boost::hana::remove_at` and `boost::hana::remove_at_c`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_REMOVE_AT_HPP #define BOOST_HANA_FWD_REMOVE_AT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> #include <cstddef> BOOST_HANA_NAMESPACE_BEGIN //! Remove the element at a given index from a sequence. //! @ingroup group-Sequence //! //! `remove_at` returns a new sequence identical to the original, except //! that the element at the given index is removed. Specifically, //! `remove_at([x0, ..., xn-1, xn, xn+1, ..., xm], n)` is a new //! sequence equivalent to `[x0, ..., xn-1, xn+1, ..., xm]`. //! //! @note //! The behavior is undefined if the index is out of the bounds of the //! sequence. //! //! //! @param xs //! A sequence from which an element is to be removed. //! //! @param n //! An non-negative `IntegralConstant` representing the index of the //! element to be removed from the sequence. The behavior is undefined //! if that index is not in the bounds of the sequence. //! //! //! Example //! ------- //! @include example/remove_at.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto remove_at = [](auto&& xs, auto const& n) { return tag-dispatched; }; #else template <typename S, typename = void> struct remove_at_impl : remove_at_impl<S, when<true>> { }; struct remove_at_t { template <typename Xs, typename N> constexpr auto operator()(Xs&& xs, N const& n) const; }; constexpr remove_at_t remove_at{}; #endif //! Equivalent to `remove_at`; provided for convenience. //! @ingroup group-Sequence //! //! //! Example //! ------- //! @include example/remove_at_c.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <std::size_t n> constexpr auto remove_at_c = [](auto&& xs) { return hana::remove_at(forwarded(xs), hana::size_c<n>); }; #else template <std::size_t n> struct remove_at_c_t; template <std::size_t n> constexpr remove_at_c_t<n> remove_at_c{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_REMOVE_AT_HPP PK �|!\ ��n n ordering.hppnu �[��� /*! @file Forward declares `boost::hana::ordering`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ORDERING_HPP #define BOOST_HANA_FWD_ORDERING_HPP #include <boost/hana/config.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns a function performing `less` after applying a transformation //! to both arguments. //! @ingroup group-Orderable //! //! `ordering` creates a total order based on the result of applying a //! function to some objects, which is especially useful in conjunction //! with algorithms that accept a custom predicate that must represent //! a total order. //! //! Specifically, `ordering` is such that //! @code //! ordering(f) == less ^on^ f //! @endcode //! or, equivalently, //! @code //! ordering(f)(x, y) == less(f(x), f(y)) //! @endcode //! //! @note //! This is not a tag-dispatched method (hence it can't be customized), //! but just a convenience function provided with the `Orderable` concept. //! //! //! Signature //! --------- //! Given a Logical `Bool` and an Orderable `B`, the signature is //! @f$ \mathrm{ordering} : (A \to B) \to (A \times A \to Bool) @f$. //! //! //! Example //! ------- //! @include example/ordering.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto ordering = [](auto&& f) { return [perfect-capture](auto&& x, auto&& y) -> decltype(auto) { return less(f(forwarded(x)), f(forwarded(y))); }; }; #else struct ordering_t { template <typename F> constexpr auto operator()(F&& f) const; }; constexpr ordering_t ordering{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ORDERING_HPP PK �|!\A�%ߵ � sum.hppnu �[��� /*! @file Forward declares `boost::hana::sum`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_SUM_HPP #define BOOST_HANA_FWD_SUM_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> #include <boost/hana/fwd/integral_constant.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Compute the sum of the numbers of a structure. //! @ingroup group-Foldable //! //! More generally, `sum` will take any foldable structure containing //! objects forming a Monoid and reduce them using the Monoid's binary //! operation. The initial state for folding is the identity of the //! Monoid. It is sometimes necessary to specify the Monoid to use; //! this is possible by using `sum<M>`. If no Monoid is specified, //! the structure will use the Monoid formed by the elements it contains //! (if it knows it), or `integral_constant_tag<int>` otherwise. Hence, //! @code //! sum<M>(xs) = fold_left(xs, zero<M or inferred Monoid>(), plus) //! sum<> = sum<integral_constant_tag<int>> //! @endcode //! //! For numbers, this will just compute the sum of the numbers in the //! `xs` structure. //! //! //! @note //! The elements of the structure are not actually required to be in the //! same Monoid, but it must be possible to perform `plus` on any two //! adjacent elements of the structure, which requires each pair of //! adjacent element to at least have a common Monoid embedding. The //! meaning of "adjacent" as used here is that two elements of the //! structure `x` and `y` are adjacent if and only if they are adjacent //! in the linearization of that structure, as documented by the Iterable //! concept. //! //! //! Why must we sometimes specify the `Monoid` by using `sum<M>`? //! ------------------------------------------------------------- //! This is because sequence tags like `tuple_tag` are not parameterized //! (by design). Hence, we do not know what kind of objects are in the //! sequence, so we can't know a `0` value of which type should be //! returned when the sequence is empty. Therefore, the type of the //! `0` to return in the empty case must be specified explicitly. Other //! foldable structures like `hana::range`s will ignore the suggested //! Monoid because they know the tag of the objects they contain. This //! inconsistent behavior is a limitation of the current design with //! non-parameterized tags, but we have no good solution for now. //! //! //! Example //! ------- //! @include example/sum.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto sum = see documentation; #else template <typename T, typename = void> struct sum_impl : sum_impl<T, when<true>> { }; template <typename M> struct sum_t { template <typename Xs> constexpr decltype(auto) operator()(Xs&& xs) const; }; template <typename M = integral_constant_tag<int>> constexpr sum_t<M> sum{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_SUM_HPP PK �|!\b�H� � first.hppnu �[��� /*! @file Forward declares `boost::hana::first`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FIRST_HPP #define BOOST_HANA_FWD_FIRST_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns the first element of a pair. //! @ingroup group-Product //! //! Note that if the `Product` actually stores the elements it contains, //! `hana::first` is required to return a lvalue reference, a lvalue //! reference to const or a rvalue reference to the first element, where //! the type of reference must match that of the pair passed to `first`. //! If the `Product` does not store the elements it contains (i.e. it //! generates them on demand), this requirement is dropped. //! //! //! Example //! ------- //! @include example/first.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto first = [](auto&& product) -> decltype(auto) { return tag-dispatched; }; #else template <typename P, typename = void> struct first_impl : first_impl<P, when<true>> { }; struct first_t { template <typename Pair> constexpr decltype(auto) operator()(Pair&& pair) const; }; constexpr first_t first{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FIRST_HPP PK �|!\��q� � is_disjoint.hppnu �[��� /*! @file Forward declares `boost::hana::is_disjoint`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_IS_DISJOINT_HPP #define BOOST_HANA_FWD_IS_DISJOINT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns whether two `Searchable`s are disjoint. //! @ingroup group-Searchable //! //! Given two `Searchable`s `xs` and `ys`, `is_disjoint` returns a //! `Logical` representing whether the keys in `xs` are disjoint from //! the keys in `ys`, i.e. whether both structures have no keys in common. //! //! //! @param xs, ys //! Two `Searchable`s to test for disjointness. //! //! //! Example //! ------- //! @include example/is_disjoint.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto is_disjoint = [](auto const& xs, auto const& ys) { return tag-dispatched; }; #else template <typename S1, typename S2, typename = void> struct is_disjoint_impl : is_disjoint_impl<S1, S2, when<true>> { }; struct is_disjoint_t { template <typename Xs, typename Ys> constexpr auto operator()(Xs&& xs, Ys&& ys) const; }; constexpr is_disjoint_t is_disjoint{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_IS_DISJOINT_HPP PK �|!\�"�k k remove_if.hppnu �[��� /*! @file Forward declares `boost::hana::remove_if`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_REMOVE_IF_HPP #define BOOST_HANA_FWD_REMOVE_IF_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Remove all the elements of a monadic structure that satisfy some //! predicate. //! @ingroup group-MonadPlus //! //! Given a monadic structure `xs` and a unary predicate, `remove_if` //! returns a new monadic structure equal to `xs` without all its elements //! that satisfy the predicate. This is equivalent to `filter` with a //! negated predicate, i.e. //! @code //! remove_if(xs, predicate) == filter(xs, negated predicated) //! @endcode //! //! //! Signature //! --------- //! Given a MonadPlus `M` and a predicate of type \f$ T \to Bool \f$ for //! some compile-time Logical `Bool`, the signature is //! \f$ //! \mathrm{remove\_if} : M(T) \times (T \to Bool) \to M(T) //! \f$ //! //! @param xs //! A monadic structure to remove some elements from. //! //! @param predicate //! A unary predicate called as `predicate(x)`, where `x` is an element //! of the structure, and returning whether `x` should be removed from //! the structure. In the current version of the library, `predicate` //! must return a compile-time Logical. //! //! //! Example //! ------- //! @include example/remove_if.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto remove_if = [](auto&& xs, auto&& predicate) { return tag-dispatched; }; #else template <typename M, typename = void> struct remove_if_impl : remove_if_impl<M, when<true>> { }; struct remove_if_t { template <typename Xs, typename Pred> constexpr auto operator()(Xs&& xs, Pred&& pred) const; }; constexpr remove_if_t remove_if{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_REMOVE_IF_HPP PK �|!\� ��y y fold_right.hppnu �[��� /*! @file Forward declares `boost::hana::fold_right`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_FOLD_RIGHT_HPP #define BOOST_HANA_FWD_FOLD_RIGHT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Right-fold of a structure using a binary operation and an optional //! initial reduction state. //! @ingroup group-Foldable //! //! `fold_right` is a right-associative fold using a binary operation. //! Given a structure containing `x1, ..., xn`, a function `f` and //! an optional initial state, `fold_right` applies `f` as follows //! @code //! f(x1, f(x2, f(x3, f(x4, ... f(xn-1, xn) ... )))) // without state //! f(x1, f(x2, f(x3, f(x4, ... f(xn, state) ... )))) // with state //! @endcode //! //! @note //! It is worth noting that the order in which the binary function should //! expect its arguments is reversed from `fold_left`. //! //! When the structure is empty, two things may arise. If an initial //! state was provided, it is returned as-is. Otherwise, if the no-state //! version of the function was used, an error is triggered. When the //! stucture contains a single element and the no-state version of the //! function was used, that single element is returned as is. //! //! //! Signature //! --------- //! Given a `Foldable` `F` and an optional initial state of tag `S`, //! the signatures for `fold_right` are //! \f[ //! \mathtt{fold\_right} : F(T) \times S \times (T \times S \to S) \to S //! \f] //! //! for the variant with an initial state, and //! \f[ //! \mathtt{fold\_right} : F(T) \times (T \times T \to T) \to T //! \f] //! //! for the variant without an initial state. //! //! @param xs //! The structure to fold. //! //! @param state //! The initial value used for folding. //! //! @param f //! A binary function called as `f(x, state)`, where `state` is the //! result accumulated so far and `x` is an element in the structure. //! For right folds without an initial state, the function is called as //! `f(x1, x2)`, where `x1` and `x2` are elements of the structure. //! //! //! Example //! ------- //! @include example/fold_right.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto fold_right = [](auto&& xs[, auto&& state], auto&& f) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename = void> struct fold_right_impl : fold_right_impl<T, when<true>> { }; struct fold_right_t { template <typename Xs, typename State, typename F> constexpr decltype(auto) operator()(Xs&& xs, State&& state, F&& f) const; template <typename Xs, typename F> constexpr decltype(auto) operator()(Xs&& xs, F&& f) const; }; constexpr fold_right_t fold_right{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_FOLD_RIGHT_HPP PK �|!\G�/ � � accessors.hppnu �[��� /*! @file Forward declares `boost::hana::accessors`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_ACCESSORS_HPP #define BOOST_HANA_FWD_ACCESSORS_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Returns a `Sequence` of pairs representing the accessors of the //! data structure. //! @ingroup group-Struct //! //! Given a `Struct` `S`, `accessors<S>()` is a `Sequence` of `Product`s //! where the first element of each pair is the "name" of a member of //! the `Struct`, and the second element of each pair is a function that //! can be used to access that member when given an object of the proper //! data type. As described in the global documentation for `Struct`, the //! accessor functions in this sequence must be move-independent. //! //! //! Example //! ------- //! @include example/accessors.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename S> constexpr auto accessors = []() { return tag-dispatched; }; #else template <typename S, typename = void> struct accessors_impl : accessors_impl<S, when<true>> { }; template <typename S> struct accessors_t; template <typename S> constexpr accessors_t<S> accessors{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_ACCESSORS_HPP PK �|!\_�B�� � drop_back.hppnu �[��� /*! @file Forward declares `boost::hana::drop_back`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_DROP_BACK_HPP #define BOOST_HANA_FWD_DROP_BACK_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Drop the last `n` elements of a finite sequence, and return the rest. //! @ingroup group-Sequence //! //! Given a finite `Sequence` `xs` with a linearization of `[x1, ..., xm]` //! and a non-negative `IntegralConstant` `n`, `drop_back(xs, n)` is a //! sequence with the same tag as `xs` whose linearization is //! `[x1, ..., xm-n]`. If `n` is not given, it defaults to an //! `IntegralConstant` with a value equal to `1`. //! //! In case `length(xs) <= n`, `drop_back` will simply drop the whole //! sequence without failing, thus returning an empty sequence. //! //! //! @param xs //! The sequence from which elements are dropped. //! //! @param n //! A non-negative `IntegralConstant` representing the number of elements //! to be dropped from the end of the sequence. If `n` is not given, it //! defaults to an `IntegralConstant` with a value equal to `1`. //! //! //! Example //! ------- //! @include example/drop_back.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto drop_back = [](auto&& xs[, auto const& n]) { return tag-dispatched; }; #else template <typename S, typename = void> struct drop_back_impl : drop_back_impl<S, when<true>> { }; struct drop_back_t { template <typename Xs, typename N> constexpr auto operator()(Xs&& xs, N const& n) const; template <typename Xs> constexpr auto operator()(Xs&& xs) const; }; constexpr drop_back_t drop_back{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_DROP_BACK_HPP PK �|!\�{�j� � unpack.hppnu �[��� /*! @file Forward declares `boost::hana::unpack`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_UNPACK_HPP #define BOOST_HANA_FWD_UNPACK_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Invoke a function with the elements of a Foldable as arguments. //! @ingroup group-Foldable //! //! Given a function and a foldable structure whose length can be known at //! compile-time, `unpack` invokes the function with the contents of that //! structure. In other words, `unpack(xs, f)` is equivalent to `f(x...)`, //! where `x...` are the elements of the structure. The length of the //! structure must be known at compile-time, because the version of `f`'s //! `operator()` that will be compiled depends on the number of arguments //! it is called with, which has to be known at compile-time. //! //! To create a function that accepts a foldable instead of variadic //! arguments, see `fuse` instead. //! //! //! @param xs //! The structure to expand into the function. //! //! @param f //! A function to be invoked as `f(x...)`, where `x...` are the elements //! of the structure as-if they had been linearized with `to<tuple_tag>`. //! //! //! Example //! ------- //! @include example/unpack.cpp //! //! //! Rationale: `unpack`'s name and parameter order //! ---------------------------------------------- //! It has been suggested a couple of times that `unpack` be called //! `apply` instead, and that the parameter order be reversed to match //! that of the [proposed std::apply function][1]. However, the name //! `apply` is already used to denote normal function application, an use //! which is consistent with the Boost MPL library and with the rest of //! the world, especially the functional programming community. //! Furthermore, the author of this library considers the proposed //! `std::apply` to have both an unfortunate name and an unfortunate //! parameter order. Indeed, taking the function as the first argument //! means that using `std::apply` with a lambda function looks like //! @code //! std::apply([](auto ...args) { //! use(args...); //! }, tuple); //! @endcode //! //! which is undeniably ugly because of the trailing `, tuple)` part //! on the last line. On the other hand, taking the function as a //! second argument allows one to write //! @code //! hana::unpack(tuple, [](auto ...args) { //! use(args...); //! }); //! @endcode //! //! which looks much nicer. Because of these observations, the author //! of this library feels justified to use `unpack` instead of `apply`, //! and to use a sane parameter order. //! //! [1]: http://en.cppreference.com/w/cpp/experimental/apply #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto unpack = [](auto&& xs, auto&& f) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename = void> struct unpack_impl : unpack_impl<T, when<true>> { }; struct unpack_t { template <typename Xs, typename F> constexpr decltype(auto) operator()(Xs&& xs, F&& f) const; }; constexpr unpack_t unpack{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_UNPACK_HPP PK �|!\�q!�� � insert_range.hppnu �[��� /*! @file Forward declares `boost::hana::insert_range`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_INSERT_RANGE_HPP #define BOOST_HANA_FWD_INSERT_RANGE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Insert several values at a given index in a sequence. //! @ingroup group-Sequence //! //! Given a sequence, an index and any `Foldable` containing elements to //! insert, `insert_range` inserts the elements in the `Foldable` at the //! given index of the sequence. //! //! @param xs //! The sequence in which values should be inserted. //! //! @param n //! The index at which elements should be inserted. This must be a //! non-negative `Constant` of an integral type, and it must also be //! true that `n < length(xs)` if `xs` is a finite sequence. //! //! @param elements //! A `Foldable` containing elements to insert in the sequence. //! //! //! Example //! ------- //! @include example/insert_range.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto insert_range = [](auto&& xs, auto&& n, auto&& elements) { return tag-dispatched; }; #else template <typename S, typename = void> struct insert_range_impl : insert_range_impl<S, when<true>> { }; struct insert_range_t { template <typename Xs, typename N, typename Elements> constexpr auto operator()(Xs&& xs, N&& n, Elements&& elements) const; }; constexpr insert_range_t insert_range{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_INSERT_RANGE_HPP PK �|!\��M� unfold_right.hppnu �[��� /*! @file Forward declares `boost::hana::unfold_right`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_UNFOLD_RIGHT_HPP #define BOOST_HANA_FWD_UNFOLD_RIGHT_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Dual operation to `fold_right` for sequences. //! @ingroup group-Sequence //! //! While `fold_right` reduces a structure to a summary value from the //! right, `unfold_right` builds a sequence from a seed value and a //! function, starting from the right. //! //! //! Signature //! --------- //! Given a `Sequence` `S`, an initial value `state` of tag `I`, an //! arbitrary Product `P` and a function \f$ f : I \to P(T, I) \f$, //! `unfold_right<S>` has the following signature: //! \f[ //! \mathtt{unfold\_right}_S : I \times (I \to P(T, I)) \to S(T) //! \f] //! //! @tparam S //! The tag of the sequence to build up. //! //! @param state //! An initial value to build the sequence from. //! //! @param f //! A function called as `f(state)`, where `state` is an initial value, //! and returning //! 1. `nothing` if it is done producing the sequence. //! 2. otherwise, `just(make<P>(x, state))`, where `state` is the new //! initial value used in the next call to `f`, `x` is an element to //! be prepended to the resulting sequence, and `P` is an arbitrary //! `Product`. //! //! //! Fun fact //! --------- //! In some cases, `unfold_right` can undo a `fold_right` operation: //! @code //! unfold_right<S>(fold_right(xs, state, f), g) == xs //! @endcode //! //! if the following holds //! @code //! g(f(x, y)) == just(make_pair(x, y)) //! g(state) == nothing //! @endcode //! //! //! Example //! ------- //! @include example/unfold_right.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED template <typename S> constexpr auto unfold_right = [](auto&& state, auto&& f) { return tag-dispatched; }; #else template <typename S, typename = void> struct unfold_right_impl : unfold_right_impl<S, when<true>> { }; template <typename S> struct unfold_right_t; template <typename S> constexpr unfold_right_t<S> unfold_right{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_UNFOLD_RIGHT_HPP PK �|!\��O[� � lexicographical_compare.hppnu �[��� /*! @file Forward declares `boost::hana::lexicographical_compare`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_LEXICOGRAPHICAL_COMPARE_HPP #define BOOST_HANA_FWD_LEXICOGRAPHICAL_COMPARE_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Short-circuiting lexicographical comparison of two `Iterable`s with //! an optional custom predicate, by default `hana::less`. //! @ingroup group-Iterable //! //! Given two `Iterable`s `xs` and `ys` and a binary predicate `pred`, //! `lexicographical_compare` returns whether `xs` is to be considered //! less than `ys` in a lexicographical ordering. Specifically, let's //! denote the linearizations of `xs` and `ys` by `[x1, x2, ...]` and //! `[y1, y2, ...]`, respectively. If the first couple satisfying the //! predicate is of the form `xi, yi`, `lexicographical_compare` returns //! true. Otherwise, if the first couple to satisfy the predicate is of //! the form `yi, xi`, `lexicographical_compare` returns false. If no //! such couple can be found, `lexicographical_compare` returns whether //! `xs` has fewer elements than `ys`. //! //! @note //! This algorithm will short-circuit as soon as it can determine that one //! sequence is lexicographically less than the other. Hence, it can be //! used to compare infinite sequences. However, for the procedure to //! terminate on infinite sequences, the predicate has to be satisfied //! at a finite index. //! //! //! Signature //! --------- //! Given two `Iterable`s `It1(T)` and `It2(T)` and a predicate //! \f$ pred : T \times T \to Bool \f$ (where `Bool` is some `Logical`), //! `lexicographical_compare` has the following signatures. For the //! variant with a provided predicate, //! \f[ //! \mathtt{lexicographical\_compare} //! : It1(T) \times It2(T) \times (T \times T \to Bool) \to Bool //! \f] //! //! for the variant without a custom predicate, `T` is required to be //! `Orderable`. The signature is then //! \f[ //! \mathtt{lexicographical\_compare} : It1(T) \times It2(T) \to Bool //! \f] //! //! @param xs, ys //! Two `Iterable`s to compare lexicographically. //! //! @param pred //! A binary function called as `pred(x, y)` and `pred(y, x)`, where `x` //! and `y` are elements of `xs` and `ys`, respectively. `pred` must //! return a `Logical` representing whether its first argument is to be //! considered as less than its second argument. Also note that `pred` //! must define a total ordering as defined by the `Orderable` concept. //! When `pred` is not provided, it defaults to `less`. //! //! //! Example //! ------- //! @include example/lexicographical_compare.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto lexicographical_compare = [](auto const& xs, auto const& ys, auto const& pred = hana::less) { return tag-dispatched; }; #else template <typename T, typename = void> struct lexicographical_compare_impl : lexicographical_compare_impl<T, when<true>> { }; struct lexicographical_compare_t { template <typename Xs, typename Ys> constexpr auto operator()(Xs const& xs, Ys const& ys) const; template <typename Xs, typename Ys, typename Pred> constexpr auto operator()(Xs const& xs, Ys const& ys, Pred const& pred) const; }; constexpr lexicographical_compare_t lexicographical_compare{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_LEXICOGRAPHICAL_COMPARE_HPP PK �|!\�� power.hppnu �[��� /*! @file Forward declares `boost::hana::power`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_POWER_HPP #define BOOST_HANA_FWD_POWER_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Elevate a ring element to its `n`th power. //! @ingroup group-Ring //! //! Specifically, `power(x, n)`, is equivalent to multiplying `x` with //! itself `n` times using the Ring's multiplication. If the power is //! equal to `zero`, the Ring's identity (`one`) is returned. //! //! @param x //! A `Ring` element that is elevated to its `n`th power. //! //! @param n //! A non-negative `IntegralConstant` representing the power to which `x` //! is elevated. //! //! //! @note //! Only the tag of `x` is used for tag-dispatching. //! //! Example //! ------- //! @include example/power.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto power = [](auto&& x, auto const& n) -> decltype(auto) { return tag-dispatched; }; #else template <typename R, typename = void> struct power_impl : power_impl<R, when<true>> { }; struct power_t { template <typename X, typename N> constexpr decltype(auto) operator()(X&& x, N const& n) const; }; constexpr power_t power{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_POWER_HPP PK �|!\�O;5 5 minus.hppnu �[��� /*! @file Forward declares `boost::hana::minus`. @copyright Louis Dionne 2013-2017 Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt) */ #ifndef BOOST_HANA_FWD_MINUS_HPP #define BOOST_HANA_FWD_MINUS_HPP #include <boost/hana/config.hpp> #include <boost/hana/core/when.hpp> BOOST_HANA_NAMESPACE_BEGIN //! Subtract two elements of a group. //! @ingroup group-Group //! //! Specifically, this performs the `Monoid` operation on the first //! argument and on the inverse of the second argument, thus being //! equivalent to: //! @code //! minus(x, y) == plus(x, negate(y)) //! @endcode //! //! //! Cross-type version of the method //! -------------------------------- //! The `minus` method is "overloaded" to handle distinct data types //! with certain properties. Specifically, `minus` is defined for //! _distinct_ data types `A` and `B` such that //! 1. `A` and `B` share a common data type `C`, as determined by the //! `common` metafunction //! 2. `A`, `B` and `C` are all `Group`s when taken individually //! 3. `to<C> : A -> B` and `to<C> : B -> C` are `Group`-embeddings, as //! determined by the `is_embedding` metafunction. //! //! The definition of `minus` for data types satisfying the above //! properties is obtained by setting //! @code //! minus(x, y) = minus(to<C>(x), to<C>(y)) //! @endcode //! //! //! Example //! ------- //! @include example/minus.cpp #ifdef BOOST_HANA_DOXYGEN_INVOKED constexpr auto minus = [](auto&& x, auto&& y) -> decltype(auto) { return tag-dispatched; }; #else template <typename T, typename U, typename = void> struct minus_impl : minus_impl<T, U, when<true>> { }; struct minus_t { template <typename X, typename Y> constexpr decltype(auto) operator()(X&& x, Y&& y) const; }; constexpr minus_t minus{}; #endif BOOST_HANA_NAMESPACE_END #endif // !BOOST_HANA_FWD_MINUS_HPP PK �|!\E E\�&