<commit_before>#ifndef D_ERRORABLE_H
#define D_ERRORABLE_H

template <typename ErrorType>
class Error {
private:
    ErrorType error_;

public:
    Error()
        : error_() {}

    explicit
    Error( const ErrorType& error )
        : error_(error) {}

    const ErrorType& get() const { return error_; }
};

template <typename ValueType, typename ErrorType=std::string>
class Errorable
{
private:
    bool valid_;
    ValueType value_;
    Error<ErrorType> error_;

public:
    Errorable()
        : valid_(true),
          value_(),
          error_() {}

    Errorable(const Error<ErrorType>& error)
        : valid_(false),
          value_(),
          error_(error) {}

    Errorable(const ValueType& value)
        : valid_(true),
          value_(value),
          error_() {}

    Errorable& operator=(const Error<ErrorType>& error)
    {
        valid_ = false;
        value_ = ValueType();
        error_ = error;
        return *this;
    }

    Errorable& operator=(const ValueType& value)
    {
        valid_ = true;
        value_ = value;
        error_ = Error<ErrorType>();
        return *this;
    }

    bool isError() const { return !valid_; }

    ValueType getValue() const { return value_; }

    Error<ErrorType> getError() const { return error_; }
};

#endif<commit_msg>fix to return reference in Errorable Getter<commit_after>#ifndef D_ERRORABLE_H
#define D_ERRORABLE_H

template <typename ErrorType>
class Error {
private:
    ErrorType error_;

public:
    Error()
        : error_() {}

    explicit
    Error( const ErrorType& error )
        : error_(error) {}

    const ErrorType& get() const { return error_; }
};

template <typename ValueType, typename ErrorType=std::string>
class Errorable
{
private:
    bool valid_;
    ValueType value_;
    Error<ErrorType> error_;

public:
    Errorable()
        : valid_(true),
          value_(),
          error_() {}

    Errorable(const Error<ErrorType>& error)
        : valid_(false),
          value_(),
          error_(error) {}

    Errorable(const ValueType& value)
        : valid_(true),
          value_(value),
          error_() {}

    Errorable& operator=(const Error<ErrorType>& error)
    {
        valid_ = false;
        value_ = ValueType();
        error_ = error;
        return *this;
    }

    Errorable& operator=(const ValueType& value)
    {
        valid_ = true;
        value_ = value;
        error_ = Error<ErrorType>();
        return *this;
    }

    bool isError() const { return !valid_; }

    const ValueType& getValue() const { return value_; }
    const Error<ErrorType>& getError() const { return error_; }
};

#endif
{'fraction_non_alphanumeric': 0.11409142425387231, 'fraction_numerical': 0.0, 'mean_word_length': 2.377551020408163, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '1026740', 'n_tokens_mistral': 787, 'n_tokens_neox': 769, 'n_words': 203}