/usr/include/boost/hof
NameSizeModeActions
detail/-0755rm
alias.hpp55520644editdlrm
always.hpp42610644editdlrm
apply.hpp83630644editdlrm
apply_eval.hpp44280644editdlrm
arg.hpp31480644editdlrm
capture.hpp54190644editdlrm
combine.hpp38770644editdlrm
compose.hpp50420644editdlrm
config.hpp61490644editdlrm
construct.hpp87740644editdlrm
decay.hpp17900644editdlrm
decorate.hpp63290644editdlrm
eval.hpp24000644editdlrm
first_of.hpp71000644editdlrm
fix.hpp63140644editdlrm
flip.hpp26900644editdlrm
flow.hpp50600644editdlrm
fold.hpp50000644editdlrm
function.hpp31290644editdlrm
function_param_limit.hpp16580644editdlrm
identity.hpp18840644editdlrm
if.hpp33140644editdlrm
implicit.hpp40410644editdlrm
indirect.hpp32680644editdlrm
infix.hpp60430644editdlrm
is_invocable.hpp17060644editdlrm
is_unpackable.hpp33410644editdlrm
lambda.hpp64580644editdlrm
lazy.hpp87290644editdlrm
lift.hpp37520644editdlrm
limit.hpp38170644editdlrm
match.hpp33310644editdlrm
mutable.hpp19880644editdlrm
pack.hpp127470644editdlrm
partial.hpp83070644editdlrm
pipable.hpp62270644editdlrm
placeholders.hpp137990644editdlrm
proj.hpp75170644editdlrm
protect.hpp21450644editdlrm
repeat.hpp41840644editdlrm
repeat_while.hpp51540644editdlrm
result.hpp36440644editdlrm
returns.hpp86070644editdlrm
reveal.hpp121870644editdlrm
reverse_fold.hpp52710644editdlrm
rotate.hpp25760644editdlrm
static.hpp23950644editdlrm
tap.hpp21180644editdlrm
unpack.hpp55880644editdlrm
unpack_sequence.hpp18100644editdlrm
version.hpp6790644editdlrm
Edit: /usr/include/boost/hof/decorate.hpp (6329B)
/*============================================================================= Copyright (c) 2015 Paul Fultz II decorate.h Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) ==============================================================================*/ #ifndef BOOST_HOF_GUARD_DECORATE_H #define BOOST_HOF_GUARD_DECORATE_H /// decorate /// ======== /// /// Description /// ----------- /// /// The `decorate` function adaptor helps create simple function decorators. /// /// A function adaptor takes a function and returns a new functions whereas a /// decorator takes some parameters and returns a function adaptor. The /// `decorate` function adaptor will return a decorator that returns a /// function adaptor. Eventually, it will invoke the function with the user- /// provided parameter and function. /// /// Synopsis /// -------- /// /// template /// constexpr decorate_adaptor decorate(F f); /// /// Semantics /// --------- /// /// assert(decorate(f)(x)(g)(xs...) == f(x, g, xs...)); /// /// Requirements /// ------------ /// /// F must be: /// /// * [ConstInvocable](ConstInvocable) /// * MoveConstructible /// /// Example /// ------- /// /// #include /// #include /// #include /// #include /// using namespace boost::hof; /// /// struct logger_f /// { /// template /// auto operator()(const std::string& message, F&& f, Ts&&... xs) const /// -> decltype(f(std::forward(xs)...)) /// { /// // Message to print out when the function is called /// std::cout << message << std::endl; /// // Call the function /// return f(std::forward(xs)...); /// } /// }; /// // The logger decorator /// BOOST_HOF_STATIC_FUNCTION(logger) = boost::hof::decorate(logger_f()); /// /// struct sum_f /// { /// template /// T operator()(T x, U y) const /// { /// return x+y; /// } /// }; /// /// BOOST_HOF_STATIC_FUNCTION(sum) = sum_f(); /// int main() { /// // Use the logger decorator to print "Calling sum" when the function is called /// assert(3 == logger("Calling sum")(sum)(1, 2)); /// } /// #include #include #include #include #include #include #include namespace boost { namespace hof { namespace detail { template struct decorator_invoke // : compressed_pair, D> : compressed_pair, F> { // typedef compressed_pair base; typedef compressed_pair, F> base; BOOST_HOF_INHERIT_CONSTRUCTOR(decorator_invoke, base) template constexpr const compressed_pair& get_pair(Ts&&... xs) const noexcept { return this->first(xs...); } template constexpr const F& base_function(Ts&&... xs) const noexcept { return this->second(xs...); } template constexpr const D& get_decorator(Ts&&... xs) const noexcept { return this->get_pair(xs...).first(xs...); } template constexpr const T& get_data(Ts&&... xs) const noexcept { return this->get_pair(xs...).second(xs...); } BOOST_HOF_RETURNS_CLASS(decorator_invoke); struct decorator_invoke_failure { template struct apply { template struct of : Failure::template of {}; }; }; struct failure : failure_map {}; template constexpr BOOST_HOF_SFINAE_RESULT(const D&, id_, id_, id_...) operator()(Ts&&... xs) const BOOST_HOF_SFINAE_RETURNS ( BOOST_HOF_MANGLE_CAST(const D&)(BOOST_HOF_CONST_THIS->get_decorator(xs...))( BOOST_HOF_MANGLE_CAST(const T&)(BOOST_HOF_CONST_THIS->get_data(xs...)), BOOST_HOF_MANGLE_CAST(const F&)(BOOST_HOF_CONST_THIS->base_function(xs...)), BOOST_HOF_FORWARD(Ts)(xs)... ) ); }; template struct decoration : compressed_pair { typedef compressed_pair base; BOOST_HOF_INHERIT_CONSTRUCTOR(decoration, base) template constexpr const D& get_decorator(Ts&&... xs) const noexcept { return this->first(xs...); } template constexpr const T& get_data(Ts&&... xs) const noexcept { return this->second(xs...); } template constexpr decorator_invoke> operator()(F f) const BOOST_HOF_NOEXCEPT(BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(decorator_invoke>, compressed_pair, detail::callable_base&&)) { return decorator_invoke>( *this, static_cast&&>(f) ); } }; } template struct decorate_adaptor : detail::callable_base { typedef decorate_adaptor fit_rewritable1_tag; typedef detail::callable_base base; BOOST_HOF_INHERIT_CONSTRUCTOR(decorate_adaptor, detail::callable_base) template constexpr const base& base_function(Ts&&... xs) const noexcept { return boost::hof::always_ref(*this)(xs...); } // TODO: Add predicate for constraints template constexpr detail::decoration operator()(T x) const BOOST_HOF_NOEXCEPT(BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(base, const base&) && BOOST_HOF_IS_NOTHROW_CONSTRUCTIBLE(T, T&&)) { return detail::decoration(this->base_function(x), static_cast(x)); } }; BOOST_HOF_DECLARE_STATIC_VAR(decorate, detail::make); }} // namespace boost::hof #endif