1/*
2 * Copyright Andrey Semashev 2024.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7/*!
8 * \file functor.hpp
9 * \author Andrey Semashev
10 * \date 2024-01-23
11 *
12 * This header contains a \c functor implementation. This is a function object
13 * that invokes a function that is specified as its template parameter.
14 */
15
16#ifndef BOOST_CORE_FUNCTOR_HPP
17#define BOOST_CORE_FUNCTOR_HPP
18
19namespace boost::core {
20
21// Block unintended ADL
22namespace functor_ns {
23
24//! A function object that invokes a function specified as its template parameter
25template< auto Function >
26struct functor
27{
28 template< typename... Args >
29 auto operator() (Args&&... args) const noexcept(noexcept(Function(static_cast< Args&& >(args)...))) -> decltype(Function(static_cast< Args&& >(args)...))
30 {
31 return Function(static_cast< Args&& >(args)...);
32 }
33};
34
35} // namespace functor_ns
36
37using functor_ns::functor;
38
39} // namespace boost::core
40
41#endif // BOOST_CORE_FUNCTOR_HPP
42

source code of boost/libs/core/include/boost/core/functor.hpp