<commit_before>// Copyright (C) 2011 - 2012 <NAME>.
//
// 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)
//
// The idea and interface is based on Boost.Optional library
// authored by <NAME>

# ifndef ___OPTIONAL_HPP___
# define ___OPTIONAL_HPP___

# include <utility>
# include <type_traits>
# include <initializer_list>
# include <cassert>
# include <functional>
# include <string>
# include <stdexcept>

# define REQUIRES(...) typename enable_if<__VA_ARGS__::value, bool>::type = false

# if defined __clang__
#  if (__clang_major__ >= 3)
#   define OPTIONAL_HAS_USING 1
#  else
#   define OPTIONAL_HAS_USING 0
#  endif
#  if (__clang_major__ > 2) || (__clang_major__ == 2) && (__clang_minor__ >= 9)
#   define OPTIONAL_HAS_THIS_RVALUE_REFS 1
#  else
#   define OPTIONAL_HAS_THIS_RVALUE_REFS 0
#  endif
# elif defined __GNUC__
#  if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
#   define OPTIONAL_HAS_USING 1
#  else
#   define OPTIONAL_HAS_USING 0
#  endif
#  if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 8 || ((__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ >= 1))))
#   define OPTIONAL_HAS_THIS_RVALUE_REFS 1
#  else
#   define OPTIONAL_HAS_THIS_RVALUE_REFS 0
#  endif
# else
#  define OPTIONAL_HAS_THIS_RVALUE_REFS 0
#  define OPTIONAL_HAS_USING 0
# endif


namespace std{


# if (defined __GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)))
    // leave it; our metafunctions are already defined.
# elif (defined __clang__) && ((__clang_major__ > 3) || (__clang_major__ == 3) && (__clang_minor__ >= 3))
    // leave it; our metafunctions are already defined.
# else

#  if OPTIONAL_HAS_USING
// the only bit GCC 4.7 and clang 3.2 don't have
template <class T>
using is_trivially_destructible = typename std::has_trivial_destructor<T>;
#  endif

#  if (defined __GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
    // leave it; remaining metafunctions are already defined.
#  elif defined __clang__
    // leave it; remaining metafunctions are already defined.
#  else


// workaround for missing traits in GCC and CLANG
template <class T>
struct is_nothrow_move_constructible
{
  constexpr static bool value = std::is_nothrow_constructible<T, T&&>::value;
};


template <class T, class U>
struct is_assignable
{
  template <class X, class Y>
  static constexpr bool has_assign(...) { return false; }

  template <class X, class Y, size_t S = sizeof(std::declval<X>() = std::declval<Y>()) >
  static constexpr bool has_assign(bool) { return true; }

  constexpr static bool value = has_assign<T, U>(true);
};


template <class T>
struct is_nothrow_move_assignable
{
  template <class X, bool has_any_move_massign>
  struct has_nothrow_move_assign {
    constexpr static bool value = false;
  };

  template <class X>
  struct has_nothrow_move_assign<X, true> {
    constexpr static bool value = noexcept( std::declval<X&>() = std::declval<X&&>() );
  };

  constexpr static bool value = has_nothrow_move_assign<T, is_assignable<T&, T&&>::value>::value;
};
// end workaround


#  endif // not as good as GCC 4.7
# endif // not as good as GCC 4.8



// 20.5.4, optional for object types
template <class T> class optional;

// 20.5.5, optional for lvalue reference types
template <class T> class optional<T&>;


// workaround: std utility functions aren't constexpr yet
template <class T> inline constexpr T&& constexpr_forward(typename std::remove_reference<T>::type& t) noexcept
{
  return static_cast<T&&>(t);
}

template <class T> inline constexpr T&& constexpr_forward(typename std::remove_reference<T>::type&& t) noexcept
{
    static_assert(!std::is_lvalue_reference<T>::value, "!!");
    return static_cast<T&&>(t);
}

template <class T> inline constexpr typename std::remove_reference<T>::type&& constexpr_move(T&& t) noexcept
{
    return static_cast<typename std::remove_reference<T>::type&&>(t);
}


#if defined NDEBUG
# define ASSERTED_EXPRESSION(CHECK, EXPR) (EXPR)
#else
# define ASSERTED_EXPRESSION(CHECK, EXPR) ((CHECK) ? (EXPR) : (fail(#CHECK, __FILE__, __LINE__), (EXPR)))
  inline void fail(const char* expr, const char* file, unsigned line)
  {
  # if defined(EMSCRIPTEN) && EMSCRIPTEN
    __assert_fail(expr, file, line, "");
  # elif defined __native_client__
    __assert(expr, line, file); // WHY.
  # elif defined __ANDROID__
    __assert(file, line, expr);
  # elif defined __clang__ || defined __GNU_LIBRARY__
    __assert(expr, file, line);
  # elif defined __GNUC__
    _assert(expr, file, line);
  # else
  #   error UNSUPPORTED COMPILER
  # endif
  }
#endif


template <typename T>
struct has_overloaded_addressof
{
  template <class X>
  static constexpr bool has_overload(...) { return false; }

  template <class X, size_t S = sizeof(std::declval< X&>().operator&()) >
  static constexpr bool has_overload(bool) { return true; }
<commit_msg>Updated Optional with fix for GCC 4.8 on OSX.<commit_after>// Copyright (C) 2011 - 2012 <NAME>.
//
// 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)
//
// The idea and interface is based on Boost.Optional library
// authored by <NAME>

# ifndef ___OPTIONAL_HPP___
# define ___OPTIONAL_HPP___

# include <utility>
# include <type_traits>
# include <initializer_list>
# include <cassert>
# include <functional>
# include <string>
# include <stdexcept>

# define REQUIRES(...) typename enable_if<__VA_ARGS__::value, bool>::type = false

# if defined __clang__
#  if (__clang_major__ >= 3)
#   define OPTIONAL_HAS_USING 1
#  else
#   define OPTIONAL_HAS_USING 0
#  endif
#  if (__clang_major__ > 2) || (__clang_major__ == 2) && (__clang_minor__ >= 9)
#   define OPTIONAL_HAS_THIS_RVALUE_REFS 1
#  else
#   define OPTIONAL_HAS_THIS_RVALUE_REFS 0
#  endif
# elif defined __GNUC__
#  if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7))
#   define OPTIONAL_HAS_USING 1
#  else
#   define OPTIONAL_HAS_USING 0
#  endif
#  if (__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ > 8 || ((__GNUC_MINOR__ == 8) && (__GNUC_PATCHLEVEL__ >= 1))))
#   define OPTIONAL_HAS_THIS_RVALUE_REFS 1
#  else
#   define OPTIONAL_HAS_THIS_RVALUE_REFS 0
#  endif
# else
#  define OPTIONAL_HAS_THIS_RVALUE_REFS 0
#  define OPTIONAL_HAS_USING 0
# endif


namespace std{


# if (defined __GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 8)))
    // leave it; our metafunctions are already defined.
# elif (defined __clang__) && ((__clang_major__ > 3) || (__clang_major__ == 3) && (__clang_minor__ >= 3))
    // leave it; our metafunctions are already defined.
# else

#  if OPTIONAL_HAS_USING
// the only bit GCC 4.7 and clang 3.2 don't have
template <class T>
using is_trivially_destructible = typename std::has_trivial_destructor<T>;
#  endif

#  if (defined __GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 7)))
    // leave it; remaining metafunctions are already defined.
#  elif defined __clang__
    // leave it; remaining metafunctions are already defined.
#  else


// workaround for missing traits in GCC and CLANG
template <class T>
struct is_nothrow_move_constructible
{
  constexpr static bool value = std::is_nothrow_constructible<T, T&&>::value;
};


template <class T, class U>
struct is_assignable
{
  template <class X, class Y>
  static constexpr bool has_assign(...) { return false; }

  template <class X, class Y, size_t S = sizeof(std::declval<X>() = std::declval<Y>()) >
  static constexpr bool has_assign(bool) { return true; }

  constexpr static bool value = has_assign<T, U>(true);
};


template <class T>
struct is_nothrow_move_assignable
{
  template <class X, bool has_any_move_massign>
  struct has_nothrow_move_assign {
    constexpr static bool value = false;
  };

  template <class X>
  struct has_nothrow_move_assign<X, true> {
    constexpr static bool value = noexcept( std::declval<X&>() = std::declval<X&&>() );
  };

  constexpr static bool value = has_nothrow_move_assign<T, is_assignable<T&, T&&>::value>::value;
};
// end workaround


#  endif // not as good as GCC 4.7
# endif // not as good as GCC 4.8



// 20.5.4, optional for object types
template <class T> class optional;

// 20.5.5, optional for lvalue reference types
template <class T> class optional<T&>;


// workaround: std utility functions aren't constexpr yet
template <class T> inline constexpr T&& constexpr_forward(typename std::remove_reference<T>::type& t) noexcept
{
  return static_cast<T&&>(t);
}

template <class T> inline constexpr T&& constexpr_forward(typename std::remove_reference<T>::type&& t) noexcept
{
    static_assert(!std::is_lvalue_reference<T>::value, "!!");
    return static_cast<T&&>(t);
}

template <class T> inline constexpr typename std::remove_reference<T>::type&& constexpr_move(T&& t) noexcept
{
    return static_cast<typename std::remove_reference<T>::type&&>(t);
}


#if defined NDEBUG
# define ASSERTED_EXPRESSION(CHECK, EXPR) (EXPR)
#else
# define ASSERTED_EXPRESSION(CHECK, EXPR) ((CHECK) ? (EXPR) : (fail(#CHECK, __FILE__, __LINE__), (EXPR)))
  inline void fail(const char* expr, const char* file, unsigned line)
  {
  # if defined(EMSCRIPTEN) && EMSCRIPTEN
    __assert_fail(expr, file, line, "");
  # elif defined __native_client__
    __assert(expr, line, file); // WHY.
  # elif defined __ANDROID__
    __assert(file, line, expr);
  # elif defined __clang__ || defined __GNU_LIBRARY__ || (defined __GNUC__ && defined __APPLE__)
    __assert(expr, file, line);
  # elif defined __GNUC__
    _assert(expr, file, line);
  # else
  #   error UNSUPPORTED COMPILER
  # endif
  }
#endif


template <typename T>
struct has_overloaded_addressof
{
  template <class X>
  static constexpr bool has_overload(...) { return false; }

  template <class X, size_t S = sizeof(std::declval< X&>().operator&()) >
  static constexpr bool has_overload(bool) { return true; }

{'fraction_non_alphanumeric': 0.1281414522697924, 'fraction_numerical': 0.012317472931359888, 'mean_word_length': 4.451001624255549, 'pattern_counts': {'":': 0, '<': 95, '<?xml version=': 0, '>': 123, 'https://': 0, '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': '4029110', 'n_tokens_mistral': 3726, 'n_tokens_neox': 3470, 'n_words': 990}