<commit_before>#pragma once

/*
cpp.hpp

Some workarounds & emulations for C++11/14 features, missed in currently used compilers & libraries.

Here be dragons
*/
/*
Copyright  2013 <NAME>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// already included in VC2012
#if defined _MSC_VER && _MSC_VER < 1700
// In VC++ 2010, there are three overloads of std::to_wstring taking long long, unsigned long long, and long double.
// Clearly, int is none of these, and no one conversion is better than another, so the conversion cannot be done implicitly/unambiguously.
// In terms of real C++11 support, this is a failing on the part of VC++ 2010's standard library implementation 
// the C++11 standard itself actually calls for nine overloads of std::to_wstring (21.5)
namespace std
{
	inline wstring to_wstring(int val) {return to_wstring(static_cast<long long>(val));}
	inline wstring to_wstring(unsigned val) {return to_wstring(static_cast<unsigned long long>(val));}
	inline wstring to_wstring(long val) {return to_wstring(static_cast<long long>(val));}
	inline wstring to_wstring(unsigned long val) {return to_wstring(static_cast<unsigned long long>(val));}
	inline wstring to_wstring(float val) {return to_wstring(static_cast<long double>(val));}
	inline wstring to_wstring(double val) {return to_wstring(static_cast<long double>(val));}

	inline string to_string(int val) {return to_string(static_cast<long long>(val));}
	inline string to_string(unsigned val) {return to_string(static_cast<unsigned long long>(val));}
	inline string to_string(long val) {return to_string(static_cast<long long>(val));}
	inline string to_string(unsigned long val) {return to_string(static_cast<unsigned long long>(val));}
	inline string to_string(float val) {return to_string(static_cast<long double>(val));}
	inline string to_string(double val) {return to_string(static_cast<long double>(val));}
};
#endif

// already included in VC2012
#if defined _MSC_VER && _MSC_VER < 1700
// hash specializations for smart pointers are missed in VC++ 2010
namespace std
{
	template<class T, class D>
	struct hash<unique_ptr<T, D>>: public unary_function<unique_ptr<T, D>, size_t>
	{
		size_t operator()(const unique_ptr<T, D>& Value) const
		{
			return hash<unique_ptr<T, D>::pointer>()(Value.get());
		}
	};

	template<class T>
	struct hash<shared_ptr<T>>: public unary_function<shared_ptr<T>, size_t>
	{
		size_t operator()(const shared_ptr<T>& Value) const
		{
			return hash<T*>()(Value.get());
		}
	};
}
#endif

// already included in VC2013
#if !defined _MSC_VER || (defined _MSC_VER && _MSC_VER < 1800)
// const, reverse and const-reverse versions of std::begin and std::end are missed in C++11,
// possibly they will be added in C++14, until then they are manually defined here:
namespace std
{
	template<class T>
	inline auto cbegin(const T& t) -> decltype(begin(t)) {return begin(t);}
	template<class T>
	inline auto cend(const T& t) -> decltype(end(t)) {return end(t);}

	template<class T>
	inline auto rbegin(T& t) -> reverse_iterator<decltype(end(t))> {return reverse_iterator<decltype(end(t))>(end(t));}
	template<class T>
	inline auto rend(T& t) -> reverse_iterator<decltype(begin(t))> {return reverse_iterator<decltype(begin(t))>(begin(t));}

	template<class T>
	inline auto crbegin(const T& t) -> decltype(rbegin(t)) {return rbegin(t);}
	template<class T>
	inline auto crend(const T& t) -> decltype(rend(t)) {return rend(t);}
};
#endif

// already included in VC2013
#if defined _MSC_VER && _MSC_VER < 1800<commit_msg>fix compilation with GCC 5<commit_after>#pragma once

/*
cpp.hpp

Some workarounds & emulations for C++11/14 features, missed in currently used compilers & libraries.

Here be dragons
*/
/*
Copyright  2013 <NAME>
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. The name of the authors may not be used to endorse or promote products
   derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

// already included in VC2012
#if defined _MSC_VER && _MSC_VER < 1700
// In VC++ 2010, there are three overloads of std::to_wstring taking long long, unsigned long long, and long double.
// Clearly, int is none of these, and no one conversion is better than another, so the conversion cannot be done implicitly/unambiguously.
// In terms of real C++11 support, this is a failing on the part of VC++ 2010's standard library implementation 
// the C++11 standard itself actually calls for nine overloads of std::to_wstring (21.5)
namespace std
{
	inline wstring to_wstring(int val) {return to_wstring(static_cast<long long>(val));}
	inline wstring to_wstring(unsigned val) {return to_wstring(static_cast<unsigned long long>(val));}
	inline wstring to_wstring(long val) {return to_wstring(static_cast<long long>(val));}
	inline wstring to_wstring(unsigned long val) {return to_wstring(static_cast<unsigned long long>(val));}
	inline wstring to_wstring(float val) {return to_wstring(static_cast<long double>(val));}
	inline wstring to_wstring(double val) {return to_wstring(static_cast<long double>(val));}

	inline string to_string(int val) {return to_string(static_cast<long long>(val));}
	inline string to_string(unsigned val) {return to_string(static_cast<unsigned long long>(val));}
	inline string to_string(long val) {return to_string(static_cast<long long>(val));}
	inline string to_string(unsigned long val) {return to_string(static_cast<unsigned long long>(val));}
	inline string to_string(float val) {return to_string(static_cast<long double>(val));}
	inline string to_string(double val) {return to_string(static_cast<long double>(val));}
};
#endif

// already included in VC2012
#if defined _MSC_VER && _MSC_VER < 1700
// hash specializations for smart pointers are missed in VC++ 2010
namespace std
{
	template<class T, class D>
	struct hash<unique_ptr<T, D>>: public unary_function<unique_ptr<T, D>, size_t>
	{
		size_t operator()(const unique_ptr<T, D>& Value) const
		{
			return hash<unique_ptr<T, D>::pointer>()(Value.get());
		}
	};

	template<class T>
	struct hash<shared_ptr<T>>: public unary_function<shared_ptr<T>, size_t>
	{
		size_t operator()(const shared_ptr<T>& Value) const
		{
			return hash<T*>()(Value.get());
		}
	};
}
#endif

// already included in VC2013 / GCC 5
#if (defined _MSC_VER && _MSC_VER < 1800) || (defined __GNUC__ && __GNUC__ < 5)
// const, reverse and const-reverse versions of std::begin and std::end are missed in C++11,
// possibly they will be added in C++14, until then they are manually defined here:
namespace std
{
	template<class T>
	inline auto cbegin(const T& t) -> decltype(begin(t)) {return begin(t);}
	template<class T>
	inline auto cend(const T& t) -> decltype(end(t)) {return end(t);}

	template<class T>
	inline auto rbegin(T& t) -> reverse_iterator<decltype(end(t))> {return reverse_iterator<decltype(end(t))>(end(t));}
	template<class T>
	inline auto rend(T& t) -> reverse_iterator<decltype(begin(t))> {return reverse_iterator<decltype(begin(t))>(begin(t));}

	template<class T>
	inline auto crbegin(const T& t) -> decltype(rbegin(t)) {return rbegin(t);}
	template<class T>
	inline auto crend(const T& t) -> decltype(rend(t)) {return rend(t);}
};
#endif

// already included in VC2013
#if defined _MSC_VER && _MSC_VER < 1800
{'fraction_non_alphanumeric': 0.10043352601156069, 'fraction_numerical': 0.01393476465730801, 'mean_word_length': 5.515803631472764, 'pattern_counts': {'":': 0, '<': 88, '<?xml version=': 0, '>': 91, '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': '6662734', 'n_tokens_mistral': 3108, 'n_tokens_neox': 2849, 'n_words': 1135}