<commit_before>#pragma once

namespace me {
	template<class T>
	class Optional {
		T *m_object;
	public:
		Optional() : m_object(0) {}

		Optional(const T& other) : m_object(new T(other)) {}

		Optional& operator=(const T& other) {
			if (m_object != 0) {
				delete m_object;
			}
			m_object = new T(other);
			return *this;
		}

		operator bool() const {
			return m_object != 0;
		}

		T& operator *() const {
			return *m_object;
		}

		T* operator ->() const {
			return m_object;
		}

		T* pointer() const {
			return m_object;
		}
	};

	// splitting.
	std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);
	std::vector<std::string> split(const std::string &s, char delim);
}<commit_msg>Use move semantics in Optional implementation.<commit_after>#pragma once

namespace me {
	// basic optional implementation.
	template<class T>
	class Optional {
		T *m_object;

	public:
		Optional() : m_object(0) { }

		// copy constructor
		Optional(const Optional<T>& other) : m_object(new T(*other)) { }

		// move constructor
		Optional(Optional<T>&& other) : m_object(other.m_object) {
			other.m_object = 0;
		}

		Optional(const T& other) : m_object(new T(other)) { }

		// destructor
		~Optional() {
			delete m_object;  // delete 0 is a no-op, so we are fine here.
		}

		// copy assignment operator
		Optional& operator=(const Optional<T>& other) {
			delete m_object;  // delete 0 is a no-op
			m_object = new T(*other);
			return *this;
		}

		Optional& operator=(const T& other) {
			delete m_object;  // delete 0 is a no-op
			m_object = new T(other);
			return *this;
		}

		// move assignment operator
		Optional& operator=(Optional<T>&& other) {
			delete m_object;  // delete 0 is a no-op
			m_object = other.m_object;
			other.m_object = 0;
			return *this;
		}

		operator bool() const {
			return m_object != 0;
		}

		T& operator *() const {
			return *m_object;
		}

		T* operator ->() const {
			return m_object;
		}

		T* pointer() const {
			return m_object;
		}
	};

	// splitting.
	std::vector<std::string> &split(const std::string &s, char delim, std::vector<std::string> &elems);
	std::vector<std::string> split(const std::string &s, char delim);
}
{'fraction_non_alphanumeric': 0.14113597246127366, 'fraction_numerical': 0.004733218588640275, 'mean_word_length': 2.6904761904761907, 'pattern_counts': {'":': 0, '<': 15, '<?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': '3964521', 'n_tokens_mistral': 935, 'n_tokens_neox': 775, 'n_words': 212}