<commit_before>#pragma once
#include <staticjson/basic.hpp>

#include <limits>
#include <string>
#include <type_traits>

namespace staticjson
{

template <class IntType>
class IntegerHandler : public BaseHandler
{
    static_assert(std::is_arithmetic<IntType>::value, "Only arithmetic types are allowed");

protected:
    IntType* m_value;

    template <class AnotherIntType>
    bool is_out_of_range(AnotherIntType a)
    {
        typedef typename std::common_type<IntType, AnotherIntType>::type CommonType;
        bool this_signed = std::numeric_limits<IntType>::is_signed,
             that_signed = std::numeric_limits<AnotherIntType>::is_signed;

        if (this_signed == that_signed)
            return CommonType(a) < CommonType(std::numeric_limits<IntType>::min())
                || CommonType(a) > CommonType(std::numeric_limits<IntType>::max());

        if (this_signed)
            return CommonType(a) > CommonType(std::numeric_limits<IntType>::max());

        return a < 0 || CommonType(a) > CommonType(std::numeric_limits<IntType>::max());
    }
    
    template<class ReceiveIntType>
    bool recieve(ReceiveIntType r, const char* actual_type)
    {
        if (is_out_of_range(r))
            return set_out_of_range(actual_type);
        *m_value = static_cast<IntType>(r);
        this->parsed = true;
        return true;
    }

public:
    explicit IntegerHandler(IntType* value) : m_value(value) {}

    bool Int(int i) override
    {
        return recieve(i, "int");
    }

    bool Uint(unsigned i) override
    {
        return receive(i, "unsigned int");
    }

    bool Int64(std::int64_t i) override
    {
        return receive(i, "std::int64_t");
    }

    bool Uint64(std::uint64_t i) override
    {
        return receive(i, "std::uint64_t");
    }

    bool Double(double d) override
    {<commit_msg>Fixed typo; staticified is_out_of_range<commit_after>#pragma once
#include <staticjson/basic.hpp>

#include <limits>
#include <string>
#include <type_traits>

namespace staticjson
{

template <class IntType>
class IntegerHandler : public BaseHandler
{
    static_assert(std::is_arithmetic<IntType>::value, "Only arithmetic types are allowed");

protected:
    IntType* m_value;

    template <class AnotherIntType>
    static constexpr typename std::enable_if<
        std::is_integral<AnotherIntType>::value,
        bool
    >::type is_out_of_range(AnotherIntType a)
    {
        typedef typename std::common_type<IntType, AnotherIntType>::type CommonType;
        typedef typename std::numeric_limits<IntType> this_limits;
        typedef typename std::numeric_limits<AnotherIntType> that_limits;
        
        return (
            (this_limits::is_signed == that_limits::is_signed) ? (
                CommonType(a) < CommonType(this_limits::min()) || CommonType(a) > CommonType(that_limits::max())
            ) : (this_limits::is_signed) ? (
                CommonType(a) > CommonType(this_limits::max())
            ) : (
                a < 0 || CommonType(a) > CommonType(this_limits::max())
            )
        );
    }
    
    template <class FloatType>
    static constexpr typename std::enable_if<
        std::is_floating_point<FloatType>::value,
        bool
    >::type is_out_of_range(FloatType f)
    {
        return static_cast<FloatType>(static_cast<IntType>(f)) != f;
    }   
    
    template <class ReceiveNumType>
    bool receive(ReceiveIntType r, const char* actual_type)
    {
        if (is_out_of_range(r))
            return set_out_of_range(actual_type);
        *m_value = static_cast<IntType>(r);
        this->parsed = true;
        return true;
    }

public:
    explicit IntegerHandler(IntType* value) : m_value(value) {}

    bool Int(int i) override
    {
        return receive(i, "int");
    }

    bool Uint(unsigned i) override
    {
        return receive(i, "unsigned int");
    }

    bool Int64(std::int64_t i) override
    {
        return receive(i, "std::int64_t");
    }

    bool Uint64(std::uint64_t i) override
    {
        return receive(i, "std::uint64_t");
    }

    bool Double(double d) override
    {
{'fraction_non_alphanumeric': 0.1166464155528554, 'fraction_numerical': 0.006318347509113001, 'mean_word_length': 2.9768115942028985, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '7574091', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1269, 'n_words': 260}