<commit_before>// Range v3 library
//
//  Copyright <NAME> 2013-2014
//  Modified in 2015-2016 by Morwenn for inclusion into cpp-sort
//
//  Use, modification and distribution is subject to 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)
//
// Project home: https://github.com/ericniebler/range-v3
//
#ifndef CPPSORT_UTILITY_AS_FUNCTION_H_
#define CPPSORT_UTILITY_AS_FUNCTION_H_

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <functional>
#include <type_traits>
#include <utility>
#include <cpp-sort/utility/static_const.h>

namespace cppsort
{
namespace utility
{
    namespace detail
    {
        struct as_function_fn
        {
        private:
            template<typename Ret, typename... Args>
            struct ptr_fn_
            {
            private:
                Ret (*pfn_)(Args...);

            public:
                ptr_fn_() = default;

                constexpr explicit ptr_fn_(Ret (*pfn)(Args...)):
                    pfn_(pfn)
                {}

                auto operator()(Args...args) const
                    -> Ret
                {
                    return (*pfn_)(std::forward<Args>(args)...);
                }
            };

        public:
            template<typename Ret, typename... Args>
            constexpr auto operator()(Ret (*p)(Args...)) const
                -> ptr_fn_<Ret, Args...>
            {
                return ptr_fn_<Ret, Args...>(p);
            }

            template<typename Ret, typename T>
            auto operator()(Ret T::* p) const
                -> decltype(std::mem_fn(p))
            {
                return std::mem_fn(p);
            }

            template<typename T, typename U = std::decay_t<T>>
            constexpr auto operator()(T && t) const
                -> std::enable_if_t<
                    !std::is_pointer<U>::value && !std::is_member_pointer<U>::value,
                    T
                >
            {
                return std::forward<T>(t);
            }
        };
    }

    namespace
    {
        constexpr auto&& as_function = static_const<
            detail::as_function_fn
        >::value;
    }<commit_msg>Changes to as_function from ericniebler/range-v3<commit_after>// Range v3 library
//
//  Copyright <NAME> 2013-2014
//  Modified in 2015-2016 by Morwenn for inclusion into cpp-sort
//
//  Use, modification and distribution is subject to 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)
//
// Project home: https://github.com/ericniebler/range-v3
//
#ifndef CPPSORT_UTILITY_AS_FUNCTION_H_
#define CPPSORT_UTILITY_AS_FUNCTION_H_

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <functional>
#include <type_traits>
#include <utility>
#include <cpp-sort/utility/static_const.h>

namespace cppsort
{
namespace utility
{
    namespace detail
    {
        struct as_function_fn
        {
            template<typename T>
            constexpr auto operator()(T&& t) const
                noexcept(noexcept(std::mem_fn(t)))
                -> std::enable_if_t<
                    std::is_member_pointer<std::decay_t<T>>::value,
                    decltype(std::mem_fn(t))
                >
            {
                return std::mem_fn(t);
            }

            template<typename T>
            constexpr auto operator()(T && t) const
                noexcept(std::is_nothrow_constructible<T, T>::value)
                -> std::enable_if_t<
                    not std::is_member_pointer<std::decay_t<T>>::value,
                    T
                >
            {
                return std::forward<T>(t);
            }
        };
    }

    namespace
    {
        constexpr auto&& as_function = static_const<
            detail::as_function_fn
        >::value;
    }
{'fraction_non_alphanumeric': 0.16931734768779055, 'fraction_numerical': 0.011989234157083434, 'mean_word_length': 1.3808969132207338, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 43, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2477555', 'n_tokens_mistral': 1197, 'n_tokens_neox': 1118, 'n_words': 235}