Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 09:53:03

0001 /*!
0002 @file
0003 Forward declares `boost::hana::adjust_if`.
0004 
0005 Copyright Louis Dionne 2013-2022
0006 Distributed under the Boost Software License, Version 1.0.
0007 (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
0008  */
0009 
0010 #ifndef BOOST_HANA_FWD_ADJUST_IF_HPP
0011 #define BOOST_HANA_FWD_ADJUST_IF_HPP
0012 
0013 #include <boost/hana/config.hpp>
0014 #include <boost/hana/core/when.hpp>
0015 
0016 
0017 namespace boost { namespace hana {
0018     //! Apply a function on all the elements of a structure satisfying a predicate.
0019     //! @ingroup group-Functor
0020     //!
0021     //! Given a Functor, a predicate `pred` and a function `f`, `adjust_if`
0022     //! will _adjust_ the elements of the Functor that satisfy the predicate
0023     //! with the function `f`. In other words, `adjust_if` will return a new
0024     //! Functor equal to the original one, except that the elements satisfying
0025     //! the predicate will be transformed with the given function. Elements
0026     //! for which the predicate is not satisfied are left untouched, and they
0027     //! are kept as-is in the resulting Functor.
0028     //!
0029     //!
0030     //! Signature
0031     //! ---------
0032     //! Given a `Functor` `F` and a `Logical` `Bool`, the signature is
0033     //! \f$
0034     //!     \mathtt{adjust\_if} : F(T) \times (T \to Bool) \times (T \to T) \to F(T)
0035     //! \f$
0036     //!
0037     //! @param xs
0038     //! The structure to adjust with `f`.
0039     //!
0040     //! @param pred
0041     //! A function called as `pred(x)` for each element of the Functor,
0042     //! and returning whether `f` should be applied on that element.
0043     //!
0044     //! @param f
0045     //! A function called as `f(x)` on the element(s) of the Functor that
0046     //! satisfy the predicate.
0047     //!
0048     //!
0049     //! Example
0050     //! -------
0051     //! @include example/adjust_if.cpp
0052 #ifdef BOOST_HANA_DOXYGEN_INVOKED
0053     constexpr auto adjust_if = [](auto&& xs, auto const& pred, auto const& f) {
0054         return tag-dispatched;
0055     };
0056 #else
0057     template <typename Xs, typename = void>
0058     struct adjust_if_impl : adjust_if_impl<Xs, when<true>> { };
0059 
0060     struct adjust_if_t {
0061         template <typename Xs, typename Pred, typename F>
0062         constexpr auto operator()(Xs&& xs, Pred const& pred, F const& f) const;
0063     };
0064 
0065     BOOST_HANA_INLINE_VARIABLE constexpr adjust_if_t adjust_if{};
0066 #endif
0067 }} // end namespace boost::hana
0068 
0069 #endif // !BOOST_HANA_FWD_ADJUST_IF_HPP