Browse Source

Revert "Update TinySTL (attempt 2). (#341)"

This reverts commit 73966ef218107e577c30cad7da6baf190cf03375.
Бранимир Караџић 10 months ago
parent
commit
fae06fa431

+ 1 - 1
include/tinystl/LICENSE

@@ -1,4 +1,4 @@
- Copyright 2012-2018 Matthew Endsley
+ Copyright 2012 Matthew Endsley
  All rights reserved
  All rights reserved
 
 
  Redistribution and use in source and binary forms, with or without
  Redistribution and use in source and binary forms, with or without

+ 5 - 4
include/tinystl/allocator.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,9 @@
 #ifndef TINYSTL_ALLOCATOR_H
 #ifndef TINYSTL_ALLOCATOR_H
 #define TINYSTL_ALLOCATOR_H
 #define TINYSTL_ALLOCATOR_H
 
 
-#include <tinystl/stddef.h>
+#include "stddef.h"
+
+#ifndef TINYSTL_ALLOCATOR
 
 
 namespace tinystl {
 namespace tinystl {
 
 
@@ -42,8 +44,7 @@ namespace tinystl {
 	};
 	};
 }
 }
 
 
-#ifndef TINYSTL_ALLOCATOR
 #	define TINYSTL_ALLOCATOR ::tinystl::allocator
 #	define TINYSTL_ALLOCATOR ::tinystl::allocator
-#endif
+#endif // TINYSTL_ALLOCATOR
 
 
 #endif
 #endif

+ 28 - 51
include/tinystl/buffer.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012-1015 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,9 +27,8 @@
 #ifndef TINYSTL_BUFFER_H
 #ifndef TINYSTL_BUFFER_H
 #define TINYSTL_BUFFER_H
 #define TINYSTL_BUFFER_H
 
 
-#include <tinystl/allocator.h>
-#include <tinystl/new.h>
-#include <tinystl/traits.h>
+#include "new.h"
+#include "traits.h"
 
 
 namespace tinystl {
 namespace tinystl {
 
 
@@ -141,7 +140,7 @@ namespace tinystl {
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
 	static inline void buffer_reserve(buffer<T, Alloc>* b, size_t capacity) {
 	static inline void buffer_reserve(buffer<T, Alloc>* b, size_t capacity) {
-		if (b->first && b->first + capacity <= b->capacity)
+		if (b->first + capacity <= b->capacity)
 			return;
 			return;
 
 
 		typedef T* pointer;
 		typedef T* pointer;
@@ -175,21 +174,19 @@ namespace tinystl {
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
 	static inline void buffer_shrink_to_fit(buffer<T, Alloc>* b) {
 	static inline void buffer_shrink_to_fit(buffer<T, Alloc>* b) {
-		if (b->capacity != b->last) {
-			if (b->last == b->first) {
-				const size_t capacity = (size_t)(b->capacity - b->first);
-				Alloc::static_deallocate(b->first, sizeof(T)*capacity);
-				b->capacity = b->first = b->last = nullptr;
-			} else {
-				const size_t capacity = (size_t)(b->capacity - b->first);
-				const size_t size = (size_t)(b->last - b->first);
-				T* newfirst = (T*)Alloc::static_allocate(sizeof(T) * size);
-				buffer_move_urange(newfirst, b->first, b->last);
-				Alloc::static_deallocate(b->first, sizeof(T) * capacity);
-				b->first = newfirst;
-				b->last = newfirst + size;
-				b->capacity = b->last;
-			}
+		if (b->last == b->first) {
+			const size_t capacity = (size_t)(b->last - b->first);
+			Alloc::static_deallocate(b->first, sizeof(T)*capacity);
+			b->capacity = b->first;
+		} else if (b->capacity != b->last) {
+			const size_t capacity = (size_t)(b->capacity - b->first);
+			const size_t size = (size_t)(b->last - b->first);
+			T* newfirst = (T*)Alloc::static_allocate(sizeof(T) * size);
+			buffer_move_urange(newfirst, b->first, b->last);
+			Alloc::static_deallocate(b->first, sizeof(T) * capacity);
+			b->first = newfirst;
+			b->last = newfirst + size;
+			b->capacity = b->last;
 		}
 		}
 	}
 	}
 
 
@@ -203,7 +200,7 @@ namespace tinystl {
 	static inline T* buffer_insert_common(buffer<T, Alloc>* b, T* where, size_t count) {
 	static inline T* buffer_insert_common(buffer<T, Alloc>* b, T* where, size_t count) {
 		const size_t offset = (size_t)(where - b->first);
 		const size_t offset = (size_t)(where - b->first);
 		const size_t newsize = (size_t)((b->last - b->first) + count);
 		const size_t newsize = (size_t)((b->last - b->first) + count);
-		if (!b->first || b->first + newsize > b->capacity)
+		if (b->first + newsize > b->capacity)
 			buffer_reserve(b, (newsize * 3) / 2);
 			buffer_reserve(b, (newsize * 3) / 2);
 
 
 		where = b->first + offset;
 		where = b->first + offset;
@@ -218,21 +215,7 @@ namespace tinystl {
 
 
 	template<typename T, typename Alloc, typename Param>
 	template<typename T, typename Alloc, typename Param>
 	static inline void buffer_insert(buffer<T, Alloc>* b, T* where, const Param* first, const Param* last) {
 	static inline void buffer_insert(buffer<T, Alloc>* b, T* where, const Param* first, const Param* last) {
-		typedef const char* pointer;
-		const size_t count = last - first;
-		const bool frombuf = ((pointer)b->first <= (pointer)first && (pointer)b->last >= (pointer)last);
-		size_t offset;
-		if (frombuf) {
-			offset = (pointer)first - (pointer)b->first;
-			if ((pointer)where <= (pointer)first)
-				offset += count * sizeof(T);
-			where = buffer_insert_common(b, where, count);
-			first = (Param*)((pointer)b->first + offset);
-			last = first + count;
-		}
-		else {
-			where = buffer_insert_common(b, where, count);
-		}
+		where = buffer_insert_common(b, where, last - first);
 		for (; first != last; ++first, ++where)
 		for (; first != last; ++first, ++where)
 			new(placeholder(), where) T(*first);
 			new(placeholder(), where) T(*first);
 	}
 	}
@@ -240,7 +223,7 @@ namespace tinystl {
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
 	static inline void buffer_insert(buffer<T, Alloc>* b, T* where, size_t count) {
 	static inline void buffer_insert(buffer<T, Alloc>* b, T* where, size_t count) {
 		where = buffer_insert_common(b, where, count);
 		where = buffer_insert_common(b, where, count);
-		for (T* end = where+count; where != end; ++where)
+		for (size_t i = 0; i < count; ++i)
 			new(placeholder(), where) T();
 			new(placeholder(), where) T();
 	}
 	}
 
 
@@ -267,28 +250,28 @@ namespace tinystl {
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
 	static inline T* buffer_erase(buffer<T, Alloc>* b, T* first, T* last) {
 	static inline T* buffer_erase(buffer<T, Alloc>* b, T* first, T* last) {
 		typedef T* pointer;
 		typedef T* pointer;
-		const size_t count = (last - first);
+		const size_t range = (last - first);
 		for (pointer it = last, end = b->last, dest = first; it != end; ++it, ++dest)
 		for (pointer it = last, end = b->last, dest = first; it != end; ++it, ++dest)
 			move(*dest, *it);
 			move(*dest, *it);
 
 
-		buffer_destroy_range(b->last - count, b->last);
+		buffer_destroy_range(b->last - range, b->last);
 
 
-		b->last -= count;
+		b->last -= range;
 		return first;
 		return first;
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
 	static inline T* buffer_erase_unordered(buffer<T, Alloc>* b, T* first, T* last) {
 	static inline T* buffer_erase_unordered(buffer<T, Alloc>* b, T* first, T* last) {
 		typedef T* pointer;
 		typedef T* pointer;
-		const size_t count = (last - first);
+		const size_t range = (last - first);
 		const size_t tail = (b->last - last);
 		const size_t tail = (b->last - last);
-		pointer it = b->last - ((count < tail) ? count : tail);
+		pointer it = b->last - ((range < tail) ? range : tail);
 		for (pointer end = b->last, dest = first; it != end; ++it, ++dest)
 		for (pointer end = b->last, dest = first; it != end; ++it, ++dest)
 			move(*dest, *it);
 			move(*dest, *it);
 
 
-		buffer_destroy_range(b->last - count, b->last);
+		buffer_destroy_range(b->last - range, b->last);
 
 
-		b->last -= count;
+		b->last -= range;
 		return first;
 		return first;
 	}
 	}
 
 
@@ -299,12 +282,6 @@ namespace tinystl {
 		b->first = other->first, b->last = other->last, b->capacity = other->capacity;
 		b->first = other->first, b->last = other->last, b->capacity = other->capacity;
 		other->first = tfirst, other->last = tlast, other->capacity = tcapacity;
 		other->first = tfirst, other->last = tlast, other->capacity = tcapacity;
 	}
 	}
-
-	template<typename T, typename Alloc>
-	static inline void buffer_move(buffer<T, Alloc>* dst, buffer<T, Alloc>* src) {
-		dst->first = src->first, dst->last = src->last, dst->capacity = src->capacity;
-		src->first = src->last = src->capacity = nullptr;
-	}
 }
 }
 
 
-#endif //TINYSTL_BUFFER_H
+#endif

+ 2 - 2
include/tinystl/hash.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
 #ifndef TINYSTL_STRINGHASH_H
 #ifndef TINYSTL_STRINGHASH_H
 #define TINYSTL_STRINGHASH_H
 #define TINYSTL_STRINGHASH_H
 
 
-#include <tinystl/stddef.h>
+#include "stddef.h"
 
 
 namespace tinystl {
 namespace tinystl {
 
 

+ 19 - 75
include/tinystl/hash_base.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,134 +27,79 @@
 #ifndef TINYSTL_HASH_BASE_H
 #ifndef TINYSTL_HASH_BASE_H
 #define TINYSTL_HASH_BASE_H
 #define TINYSTL_HASH_BASE_H
 
 
-#include <tinystl/stddef.h>
-#include <tinystl/traits.h>
+#include "stddef.h"
 
 
 namespace tinystl {
 namespace tinystl {
 
 
 	template<typename Key, typename Value>
 	template<typename Key, typename Value>
 	struct pair {
 	struct pair {
+		typedef Key first_type;
+		typedef Value second_type;
+
 		pair();
 		pair();
-		pair(const pair& other);
-		pair(pair&& other);
 		pair(const Key& key, const Value& value);
 		pair(const Key& key, const Value& value);
-		pair(Key&& key, Value&& value);
-
-		pair& operator=(const pair& other);
-		pair& operator=(pair&& other);
 
 
 		Key first;
 		Key first;
 		Value second;
 		Value second;
-
-		using first_type = Key;
-		using second_type = Value;
 	};
 	};
 
 
 	template<typename Key, typename Value>
 	template<typename Key, typename Value>
-	inline pair<Key, Value>::pair() {
-	}
-
-	template<typename Key, typename Value>
-	inline pair<Key, Value>::pair(const pair& other)
-		: first(other.first)
-		, second(other.second)
-	{
-	}
-
-	template<typename Key, typename Value>
-	inline pair<Key, Value>::pair(pair&& other)
-		: first(static_cast<Key&&>(other.first))
-		, second(static_cast<Value&&>(other.second))
-	{
+	pair<Key, Value>::pair() {
 	}
 	}
 
 
 	template<typename Key, typename Value>
 	template<typename Key, typename Value>
-	inline pair<Key, Value>::pair(const Key& key, const Value& value)
+	pair<Key, Value>::pair(const Key& key, const Value& value)
 		: first(key)
 		: first(key)
 		, second(value)
 		, second(value)
 	{
 	{
 	}
 	}
 
 
 	template<typename Key, typename Value>
 	template<typename Key, typename Value>
-	inline pair<Key, Value>::pair(Key&& key, Value&& value)
-		: first(static_cast<Key&&>(key))
-		, second(static_cast<Value&&>(value))
-	{
-	}
-
-	template<typename Key, typename Value>
-	inline pair<Key, Value>& pair<Key, Value>::operator=(const pair& other) {
-		first = other.first;
-		second = other.second;
-		return *this;
-	}
-
-	template<typename Key, typename Value>
-	inline pair<Key, Value>& pair<Key, Value>::operator=(pair&& other) {
-		first = static_cast<Key&&>(other.first);
-		second = static_cast<Value&&>(other.second);
-		return *this;
-	}
-
-	template<typename Key, typename Value>
-	static inline pair<typename remove_const_reference<Key>::type, typename remove_const_reference<Value>::type>
-	make_pair(Key&& key, Value&& value) {
-		return pair<typename remove_const_reference<Key>::type, typename remove_const_reference<Value>::type>(
-				  static_cast<Key&&>(key)
-				, static_cast<Value&&>(value)
-			);
+	static inline pair<Key, Value> make_pair(const Key& key, const Value& value) {
+		return pair<Key, Value>(key, value);
 	}
 	}
 
 
 
 
 	template<typename Key, typename Value>
 	template<typename Key, typename Value>
 	struct unordered_hash_node {
 	struct unordered_hash_node {
 		unordered_hash_node(const Key& key, const Value& value);
 		unordered_hash_node(const Key& key, const Value& value);
-		unordered_hash_node(Key&& key, Value&& value);
 
 
 		const Key first;
 		const Key first;
 		Value second;
 		Value second;
 		unordered_hash_node* next;
 		unordered_hash_node* next;
 		unordered_hash_node* prev;
 		unordered_hash_node* prev;
+
+	private:
+		unordered_hash_node& operator=(const unordered_hash_node&);
 	};
 	};
 
 
 	template<typename Key, typename Value>
 	template<typename Key, typename Value>
-	inline unordered_hash_node<Key, Value>::unordered_hash_node(const Key& key, const Value& value)
+	unordered_hash_node<Key, Value>::unordered_hash_node(const Key& key, const Value& value)
 		: first(key)
 		: first(key)
 		, second(value)
 		, second(value)
 	{
 	{
 	}
 	}
 
 
-	template<typename Key, typename Value>
-	inline unordered_hash_node<Key, Value>::unordered_hash_node(Key&& key, Value&& value)
-		: first(static_cast<Key&&>(key))
-		, second(static_cast<Value&&>(value))
-	{
-	}
-
 	template <typename Key>
 	template <typename Key>
 	struct unordered_hash_node<Key, void> {
 	struct unordered_hash_node<Key, void> {
-		explicit unordered_hash_node(const Key& key);
-		explicit unordered_hash_node(Key&& key);
+		unordered_hash_node(const Key& key);
 
 
 		const Key first;
 		const Key first;
 		unordered_hash_node* next;
 		unordered_hash_node* next;
 		unordered_hash_node* prev;
 		unordered_hash_node* prev;
+
+	private:
+		unordered_hash_node& operator=(const unordered_hash_node&);
 	};
 	};
 
 
 	template<typename Key>
 	template<typename Key>
-	inline unordered_hash_node<Key, void>::unordered_hash_node(const Key& key)
+	unordered_hash_node<Key, void>::unordered_hash_node(const Key& key)
 		: first(key)
 		: first(key)
 	{
 	{
 	}
 	}
 
 
-	template<typename Key>
-	inline unordered_hash_node<Key, void>::unordered_hash_node(Key&& key)
-		: first(static_cast<Key&&>(key))
-	{
-	}
-
 	template<typename Key, typename Value>
 	template<typename Key, typename Value>
-	static inline void unordered_hash_node_insert(unordered_hash_node<Key, Value>* node, size_t hash, unordered_hash_node<Key, Value>** buckets, size_t nbuckets) {
+	static void unordered_hash_node_insert(unordered_hash_node<Key, Value>* node, size_t hash, unordered_hash_node<Key, Value>** buckets, size_t nbuckets) {
 		size_t bucket = hash & (nbuckets - 1);
 		size_t bucket = hash & (nbuckets - 1);
 
 
 		unordered_hash_node<Key, Value>* it = buckets[bucket + 1];
 		unordered_hash_node<Key, Value>* it = buckets[bucket + 1];
@@ -278,7 +223,6 @@ namespace tinystl {
 
 
 	template<typename Node, typename Key>
 	template<typename Node, typename Key>
 	static inline Node unordered_hash_find(const Key& key, Node* buckets, size_t nbuckets) {
 	static inline Node unordered_hash_find(const Key& key, Node* buckets, size_t nbuckets) {
-		if (!buckets) return 0;
 		const size_t bucket = hash(key) & (nbuckets - 2);
 		const size_t bucket = hash(key) & (nbuckets - 2);
 		for (Node it = buckets[bucket], end = buckets[bucket+1]; it != end; it = it->next)
 		for (Node it = buckets[bucket], end = buckets[bucket+1]; it != end; it = it->next)
 			if (it->first == key)
 			if (it->first == key)

+ 2 - 2
include/tinystl/new.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
 #ifndef TINYSTL_NEW_H
 #ifndef TINYSTL_NEW_H
 #define TINYSTL_NEW_H
 #define TINYSTL_NEW_H
 
 
-#include <tinystl/stddef.h>
+#include "stddef.h"
 
 
 namespace tinystl {
 namespace tinystl {
 
 

+ 2 - 5
include/tinystl/stddef.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -29,13 +29,10 @@
 
 
 #if defined(_WIN64)
 #if defined(_WIN64)
 	typedef long long unsigned int size_t;
 	typedef long long unsigned int size_t;
-	typedef long long int ptrdiff_t;
 #elif defined(_WIN32)
 #elif defined(_WIN32)
 	typedef unsigned int size_t;
 	typedef unsigned int size_t;
-	typedef int ptrdiff_t;
-#elif defined (__linux__) && defined(__SIZE_TYPE__) && defined(__PTRDIFF_TYPE__)
+#elif defined (__linux__) && defined(__SIZE_TYPE__)
 	typedef __SIZE_TYPE__ size_t;
 	typedef __SIZE_TYPE__ size_t;
-	typedef __PTRDIFF_TYPE__ ptrdiff_t;
 #else
 #else
 #	include <stddef.h>
 #	include <stddef.h>
 #endif
 #endif

+ 96 - 139
include/tinystl/string.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,37 +27,34 @@
 #ifndef TINYSTL_STRING_H
 #ifndef TINYSTL_STRING_H
 #define TINYSTL_STRING_H
 #define TINYSTL_STRING_H
 
 
-#include <tinystl/allocator.h>
-#include <tinystl/stddef.h>
-#include <tinystl/hash.h>
+#include <string.h> // strlen
+#include "stddef.h"
+#include "hash.h"
 
 
 namespace tinystl {
 namespace tinystl {
 
 
-	template<typename Allocator>
-	class basic_string {
+	template<typename Alloc>
+	class stringT {
 	public:
 	public:
-		basic_string();
-		basic_string(const basic_string& other);
-		basic_string(basic_string&& other);
-		basic_string(const char* sz);
-		basic_string(const char* sz, size_t len);
-		~basic_string();
+		stringT();
+		stringT(const stringT<Alloc>& other);
+		stringT(const char* sz);
+		stringT(const char* sz, size_t len);
+		~stringT();
 
 
-		basic_string& operator=(const basic_string& other);
-		basic_string& operator=(basic_string&& other);
+		stringT<Alloc>& operator=(const stringT<Alloc>& other);
 
 
 		const char* c_str() const;
 		const char* c_str() const;
 		size_t size() const;
 		size_t size() const;
+		bool empty() const;
 
 
-		void reserve(size_t size);
-		void resize(size_t size);
+		void reserve(size_t _size);
+		void resize(size_t _size);
 
 
-		void clear();
 		void append(const char* first, const char* last);
 		void append(const char* first, const char* last);
-		void assign(const char* s, size_t n);
+		void append(const char* str);
 
 
-		void shrink_to_fit();
-		void swap(basic_string& other);
+		void swap(stringT<Alloc>& other);
 
 
 	private:
 	private:
 		typedef char* pointer;
 		typedef char* pointer;
@@ -66,11 +63,13 @@ namespace tinystl {
 		pointer m_capacity;
 		pointer m_capacity;
 
 
 		static const size_t c_nbuffer = 12;
 		static const size_t c_nbuffer = 12;
-		char m_buffer[12]{0};
+		char m_buffer[12];
 	};
 	};
 
 
-	template<typename allocator>
-	inline basic_string<allocator>::basic_string()
+	typedef stringT<TINYSTL_ALLOCATOR> string;
+
+	template<typename Alloc>
+	inline stringT<Alloc>::stringT()
 		: m_first(m_buffer)
 		: m_first(m_buffer)
 		, m_last(m_buffer)
 		, m_last(m_buffer)
 		, m_capacity(m_buffer + c_nbuffer)
 		, m_capacity(m_buffer + c_nbuffer)
@@ -78,8 +77,8 @@ namespace tinystl {
 		resize(0);
 		resize(0);
 	}
 	}
 
 
-	template<typename allocator>
-	inline basic_string<allocator>::basic_string(const basic_string& other)
+	template<typename Alloc>
+	inline stringT<Alloc>::stringT(const stringT<Alloc>& other)
 		: m_first(m_buffer)
 		: m_first(m_buffer)
 		, m_last(m_buffer)
 		, m_last(m_buffer)
 		, m_capacity(m_buffer + c_nbuffer)
 		, m_capacity(m_buffer + c_nbuffer)
@@ -88,27 +87,8 @@ namespace tinystl {
 		append(other.m_first, other.m_last);
 		append(other.m_first, other.m_last);
 	}
 	}
 
 
-	template<typename allocator>
-	inline basic_string<allocator>::basic_string(basic_string&& other)
-	{
-		if (other.m_first == other.m_buffer) {
-			m_first = m_buffer;
-			m_last = m_buffer;
-			m_capacity = m_buffer + c_nbuffer;
-			reserve(other.size());
-			append(other.m_first, other.m_last);
-		} else {
-			m_first = other.m_first;
-			m_last = other.m_last;
-			m_capacity = other.m_capacity;
-		}
-		other.m_first = other.m_last = other.m_buffer;
-		other.m_capacity = other.m_buffer + c_nbuffer;
-		other.resize(0);
-	}
-
-	template<typename allocator>
-	inline basic_string<allocator>::basic_string(const char* sz)
+	template<typename Alloc>
+	inline stringT<Alloc>::stringT(const char* sz)
 		: m_first(m_buffer)
 		: m_first(m_buffer)
 		, m_last(m_buffer)
 		, m_last(m_buffer)
 		, m_capacity(m_buffer + c_nbuffer)
 		, m_capacity(m_buffer + c_nbuffer)
@@ -121,8 +101,8 @@ namespace tinystl {
 		append(sz, sz + len);
 		append(sz, sz + len);
 	}
 	}
 
 
-	template<typename allocator>
-	inline basic_string<allocator>::basic_string(const char* sz, size_t len)
+	template<typename Alloc>
+	inline stringT<Alloc>::stringT(const char* sz, size_t len)
 		: m_first(m_buffer)
 		: m_first(m_buffer)
 		, m_last(m_buffer)
 		, m_last(m_buffer)
 		, m_capacity(m_buffer + c_nbuffer)
 		, m_capacity(m_buffer + c_nbuffer)
@@ -131,73 +111,68 @@ namespace tinystl {
 		append(sz, sz + len);
 		append(sz, sz + len);
 	}
 	}
 
 
-	template<typename allocator>
-	inline basic_string<allocator>::~basic_string() {
+	template<typename Alloc>
+	inline stringT<Alloc>::~stringT() {
 		if (m_first != m_buffer)
 		if (m_first != m_buffer)
-			allocator::static_deallocate(m_first, m_capacity - m_first);
-	}
-
-	template<typename allocator>
-	inline basic_string<allocator>& basic_string<allocator>::operator=(const basic_string& other) {
-		basic_string(other).swap(*this);
-		return *this;
+			Alloc::static_deallocate(m_first, m_capacity - m_first);
 	}
 	}
 
 
-	template<typename allocator>
-	inline basic_string<allocator>& basic_string<allocator>::operator=(basic_string&& other) {
-		basic_string(static_cast<basic_string&&>(other)).swap(*this);
+	template<typename Alloc>
+	inline stringT<Alloc>& stringT<Alloc>::operator=(const stringT<Alloc>& other) {
+		stringT<Alloc>(other).swap(*this);
 		return *this;
 		return *this;
 	}
 	}
 
 
-	template<typename allocator>
-	inline const char* basic_string<allocator>::c_str() const {
+	template<typename Alloc>
+	inline const char* stringT<Alloc>::c_str() const {
 		return m_first;
 		return m_first;
 	}
 	}
 
 
-	template<typename allocator>
-	inline size_t basic_string<allocator>::size() const
+	template<typename Alloc>
+	inline size_t stringT<Alloc>::size() const
 	{
 	{
 		return (size_t)(m_last - m_first);
 		return (size_t)(m_last - m_first);
 	}
 	}
 
 
-	template<typename allocator>
-	inline void basic_string<allocator>::reserve(size_t capacity) {
-		if (m_first + capacity + 1 <= m_capacity)
+	template<typename Alloc>
+	inline bool stringT<Alloc>::empty() const
+	{
+		return 0 == size();
+	}
+
+	template<typename Alloc>
+	inline void stringT<Alloc>::reserve(size_t capacity) {
+		if (m_first + capacity + 1 <= m_capacity) {
 			return;
 			return;
+		}
 
 
-		const size_t size = (size_t)(m_last - m_first);
+		const size_t _size = (size_t)(m_last - m_first);
 
 
-		pointer newfirst = (pointer)allocator::static_allocate(capacity + 1);
-		for (pointer it = m_first, newit = newfirst, end = m_last; it != end; ++it, ++newit)
+		pointer newfirst = (pointer)Alloc::static_allocate(capacity + 1);
+		for (pointer it = m_first, newit = newfirst, end = m_last; it != end; ++it, ++newit) {
 			*newit = *it;
 			*newit = *it;
-		if (m_first != m_buffer)
-			allocator::static_deallocate(m_first, m_capacity - m_first);
+		}
+
+		if (m_first != m_buffer) {
+			Alloc::static_deallocate(m_first, m_capacity - m_first);
+		}
 
 
 		m_first = newfirst;
 		m_first = newfirst;
-		m_last = newfirst + size;
+		m_last = newfirst + _size;
 		m_capacity = m_first + capacity;
 		m_capacity = m_first + capacity;
 	}
 	}
 
 
-	template<typename allocator>
-	inline void basic_string<allocator>::resize(size_t size) {
-		const size_t prevSize = m_last-m_first;
-		reserve(size);
-		if (size > prevSize)
-			for (pointer it = m_last, end = m_first + size + 1; it < end; ++it)
-				*it = 0;
-		else if (m_last != m_first)
-			m_first[size] = 0;
-
-		m_last = m_first + size;
-	}
+	template<typename Alloc>
+	inline void stringT<Alloc>::resize(size_t _size) {
+		reserve(_size);
+		for (pointer it = m_last, end = m_first + _size + 1; it < end; ++it)
+			*it = 0;
 
 
-	template<typename allocator>
-	inline void basic_string<allocator>::clear() {
-		resize(0);
+		m_last += _size;
 	}
 	}
 
 
-	template<typename allocator>
-	inline void basic_string<allocator>::append(const char* first, const char* last) {
+	template<typename Alloc>
+	inline void stringT<Alloc>::append(const char* first, const char* last) {
 		const size_t newsize = (size_t)((m_last - m_first) + (last - first) + 1);
 		const size_t newsize = (size_t)((m_last - m_first) + (last - first) + 1);
 		if (m_first + newsize > m_capacity)
 		if (m_first + newsize > m_capacity)
 			reserve((newsize * 3) / 2);
 			reserve((newsize * 3) / 2);
@@ -207,62 +182,46 @@ namespace tinystl {
 		*m_last = 0;
 		*m_last = 0;
 	}
 	}
 
 
-	template<typename allocator>
-	inline void basic_string<allocator>::assign(const char* sz, size_t n) {
-		clear();
-		append(sz, sz+n);
+	template<typename Alloc>
+	inline void stringT<Alloc>::append(const char* str) {
+		append(str, str + strlen(str) );
 	}
 	}
 
 
-	template<typename allocator>
-	inline void basic_string<allocator>::shrink_to_fit() {
-		if (m_first == m_buffer) {
-		} else if (m_last == m_first) {
-			const size_t capacity = (size_t)(m_capacity - m_first);
-			if (capacity)
-				allocator::static_deallocate(m_first, capacity+1);
-			m_capacity = m_first;
-		} else if (m_capacity != m_last) {
-			const size_t size = (size_t)(m_last - m_first);
-			char* newfirst = (pointer)allocator::static_allocate(size+1);
-			for (pointer in = m_first, out = newfirst; in != m_last + 1; ++in, ++out)
-				*out = *in;
-			if (m_first != m_capacity)
-				allocator::static_deallocate(m_first, m_capacity+1-m_first);
-			m_first = newfirst;
-			m_last = newfirst+size;
-			m_capacity = m_last;
-		}
-	}
+	template<typename Alloc>
+	inline void stringT<Alloc>::swap(stringT<Alloc>& other) {
+		const pointer tfirst = m_first, tlast = m_last, tcapacity = m_capacity;
+		m_first = other.m_first, m_last = other.m_last, m_capacity = other.m_capacity;
+		other.m_first = tfirst, other.m_last = tlast, other.m_capacity = tcapacity;
 
 
-	template<typename allocator>
-	inline void basic_string<allocator>::swap(basic_string& other) {
-		{
-			const pointer tfirst = m_first, tlast = m_last, tcapacity = m_capacity;
-			m_first = other.m_first, m_last = other.m_last, m_capacity = other.m_capacity;
-			other.m_first = tfirst, other.m_last = tlast, other.m_capacity = tcapacity;
-		}
+		char tbuffer[c_nbuffer];
 
 
-		for (size_t i = 0; i < c_nbuffer; ++i) {
-			const char temp = m_buffer[i];
-			m_buffer[i] = other.m_buffer[i];
-			other.m_buffer[i] = temp;
+		if (m_first == other.m_buffer)
+			for  (pointer it = other.m_buffer, end = m_last, out = tbuffer; it != end; ++it, ++out)
+				*out = *it;
+
+		if (other.m_first == m_buffer) {
+			other.m_last = other.m_last - other.m_first + other.m_buffer;
+			other.m_first = other.m_buffer;
+			other.m_capacity = other.m_buffer + c_nbuffer;
+
+			for (pointer it = other.m_first, end = other.m_last, in = m_buffer; it != end; ++it, ++in)
+				*it = *in;
+			*other.m_last = 0;
 		}
 		}
+
 		if (m_first == other.m_buffer) {
 		if (m_first == other.m_buffer) {
-			int len = m_last - m_first;
+			m_last = m_last - m_first + m_buffer;
 			m_first = m_buffer;
 			m_first = m_buffer;
-			m_last = m_buffer + len;
 			m_capacity = m_buffer + c_nbuffer;
 			m_capacity = m_buffer + c_nbuffer;
-		}
-		if (other.m_first == m_buffer) {
-			int len = other.m_last - other.m_first;
-			other.m_first = other.m_buffer;
-			other.m_last = other.m_buffer + len;
-			other.m_capacity = other.m_buffer + c_nbuffer;
+
+			for (pointer it = m_first, end = m_last, in = tbuffer; it != end; ++it, ++in)
+				*it = *in;
+			*m_last = 0;
 		}
 		}
 	}
 	}
 
 
-	template<typename allocatorl, typename allocatorr>
-	inline bool operator==(const basic_string<allocatorl>& lhs, const basic_string<allocatorr>& rhs) {
+	template<typename Alloc>
+	inline bool operator==(const stringT<Alloc>& lhs, const stringT<Alloc>& rhs) {
 		typedef const char* pointer;
 		typedef const char* pointer;
 
 
 		const size_t lsize = lhs.size(), rsize = rhs.size();
 		const size_t lsize = lhs.size(), rsize = rhs.size();
@@ -278,12 +237,10 @@ namespace tinystl {
 		return true;
 		return true;
 	}
 	}
 
 
-	template<typename allocator>
-	static inline size_t hash(const basic_string<allocator>& value) {
+	template<typename Alloc>
+	static inline size_t hash(const stringT<Alloc>& value) {
 		return hash_string(value.c_str(), value.size());
 		return hash_string(value.c_str(), value.size());
 	}
 	}
-
-	typedef basic_string<TINYSTL_ALLOCATOR> string;
 }
 }
 
 
 #endif
 #endif

+ 0 - 147
include/tinystl/string_view.h

@@ -1,147 +0,0 @@
-/*-
- * Copyright 2012-1017 Matthew Endsley
- * All rights reserved
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted providing 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.
- *
- * 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.
- */
-
-#ifndef TINYSTL_STRING_VIEW_H
-#define TINYSTL_STRING_VIEW_H
-
-#include <tinystl/stddef.h>
-
-namespace tinystl {
-
-	class string_view
-	{
-	public:
-		typedef char value_type;
-		typedef char* pointer;
-		typedef const char* const_pointer;
-		typedef char& reference;
-		typedef const char& const_reference;
-		typedef const_pointer iterator;
-		typedef const_pointer const_iterator;
-		typedef size_t size_type;
-		typedef ptrdiff_t difference_type;
-
-		static constexpr size_type npos = size_type(-1);
-
-		constexpr string_view();
-		constexpr string_view(const char* s, size_type count);
-		constexpr string_view(const char* s);
-		constexpr string_view(const string_view&) = default;
-		string_view& operator=(const string_view&) = default;
-
-		constexpr const char* data() const;
-		constexpr char operator[](size_type pos) const;
-		constexpr size_type size() const;
-		constexpr bool empty() const;
-		constexpr iterator begin() const;
-		constexpr const_iterator cbegin() const;
-		constexpr iterator end() const;
-		constexpr const_iterator cend() const;
-		constexpr string_view substr(size_type pos = 0, size_type count = npos) const;
-		constexpr void swap(string_view& v);
-
-	private:
-		string_view(decltype(nullptr)) = delete;
-
-		static constexpr size_type strlen(const char*);
-
-		const char* m_str;
-		size_type m_size;
-	};
-
-	constexpr string_view::string_view()
-		: m_str(nullptr)
-		, m_size(0)
-	{
-	}
-
-	constexpr string_view::string_view(const char* s, size_type count)
-		: m_str(s)
-		, m_size(count)
-	{
-	}
-
-	constexpr string_view::string_view(const char* s)
-		: m_str(s)
-		, m_size(strlen(s))
-	{
-	}
-
-	constexpr const char* string_view::data() const {
-		return m_str;
-	}
-
-	constexpr char string_view::operator[](size_type pos) const {
-		return m_str[pos];
-	}
-
-	constexpr string_view::size_type string_view::size() const {
-		return m_size;
-	}
-
-	constexpr bool string_view::empty() const {
-		return 0 == m_size;
-	}
-
-	constexpr string_view::iterator string_view::begin() const {
-		return m_str;
-	}
-
-	constexpr string_view::const_iterator string_view::cbegin() const {
-		return m_str;
-	}
-
-	constexpr string_view::iterator string_view::end() const {
-		return m_str + m_size;
-	}
-
-	constexpr string_view::const_iterator string_view::cend() const {
-		return m_str + m_size;
-	}
-
-	constexpr string_view string_view::substr(size_type pos, size_type count) const {
-		return string_view(m_str + pos, npos == count ? m_size - pos : count);
-	}
-
-	constexpr void string_view::swap(string_view& v) {
-		const char* strtmp = m_str;
-		size_type sizetmp = m_size;
-		m_str = v.m_str;
-		m_size = v.m_size;
-		v.m_str = strtmp;
-		v.m_size = sizetmp;
-	}
-
-	constexpr string_view::size_type string_view::strlen(const char* s) {
-		for (size_t len = 0; ; ++len) {
-			if (0 == s[len]) {
-				return len;
-			}
-		}
-	}
-}
-
-#endif // TINYSTL_STRING_VIEW_H

+ 3 - 43
include/tinystl/traits.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,9 +27,9 @@
 #ifndef TINYSTL_TRAITS_H
 #ifndef TINYSTL_TRAITS_H
 #define TINYSTL_TRAITS_H
 #define TINYSTL_TRAITS_H
 
 
-#include <tinystl/new.h>
+#include "new.h"
 
 
-#if defined(__GNUC__)
+#if defined(__GNUC__) && defined(__is_pod)
 #	define TINYSTL_TRY_POD_OPTIMIZATION(t) __is_pod(t)
 #	define TINYSTL_TRY_POD_OPTIMIZATION(t) __is_pod(t)
 #elif defined(_MSC_VER)
 #elif defined(_MSC_VER)
 #	define TINYSTL_TRY_POD_OPTIMIZATION(t) (!__is_class(t) || __is_pod(t))
 #	define TINYSTL_TRY_POD_OPTIMIZATION(t) (!__is_class(t) || __is_pod(t))
@@ -80,46 +80,6 @@ namespace tinystl {
 	static inline void move_construct(T* a, T& b) {
 	static inline void move_construct(T* a, T& b) {
 		move_construct_impl(a, b, (T*)0);
 		move_construct_impl(a, b, (T*)0);
 	}
 	}
-
-	template<typename T>
-	struct remove_reference {
-		typedef T type;
-	};
-
-	template<typename T>
-	struct remove_reference<T&> {
-		typedef T type;
-	};
-
-	template<typename T>
-	struct remove_reference<T&&> {
-		typedef T type;
-	};
-
-	template<typename T>
-	struct remove_const {
-		typedef T type;
-	};
-
-	template<typename T>
-	struct remove_const<const T> {
-		typedef T type;
-	};
-
-	template<typename T>
-	struct remove_const<const T&> {
-		typedef T& type;
-	};
-
-	template<typename T>
-	struct remove_const<const T&&> {
-		typedef T&& type;
-	};
-
-	template<typename T>
-	struct remove_const_reference {
-		typedef typename remove_reference<typename remove_const<T>::type>::type type;
-	};
 }
 }
 
 
 #endif
 #endif

+ 48 - 111
include/tinystl/unordered_map.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,10 +27,9 @@
 #ifndef TINYSTL_UNORDERED_MAP_H
 #ifndef TINYSTL_UNORDERED_MAP_H
 #define TINYSTL_UNORDERED_MAP_H
 #define TINYSTL_UNORDERED_MAP_H
 
 
-#include <tinystl/allocator.h>
-#include <tinystl/buffer.h>
-#include <tinystl/hash.h>
-#include <tinystl/hash_base.h>
+#include "buffer.h"
+#include "hash.h"
+#include "hash_base.h"
 
 
 namespace tinystl {
 namespace tinystl {
 
 
@@ -39,14 +38,13 @@ namespace tinystl {
 	public:
 	public:
 		unordered_map();
 		unordered_map();
 		unordered_map(const unordered_map& other);
 		unordered_map(const unordered_map& other);
-		unordered_map(unordered_map&& other);
 		~unordered_map();
 		~unordered_map();
 
 
 		unordered_map& operator=(const unordered_map& other);
 		unordered_map& operator=(const unordered_map& other);
-		unordered_map& operator=(unordered_map&& other);
 
 
-		typedef pair<Key, Value> value_type;
 
 
+		typedef pair<Key, Value> value_type;
+		
 		typedef unordered_hash_iterator<const unordered_hash_node<Key, Value> > const_iterator;
 		typedef unordered_hash_iterator<const unordered_hash_node<Key, Value> > const_iterator;
 		typedef unordered_hash_iterator<unordered_hash_node<Key, Value> > iterator;
 		typedef unordered_hash_iterator<unordered_hash_node<Key, Value> > iterator;
 
 
@@ -63,7 +61,6 @@ namespace tinystl {
 		const_iterator find(const Key& key) const;
 		const_iterator find(const Key& key) const;
 		iterator find(const Key& key);
 		iterator find(const Key& key);
 		pair<iterator, bool> insert(const pair<Key, Value>& p);
 		pair<iterator, bool> insert(const pair<Key, Value>& p);
-		pair<iterator, bool> emplace(pair<Key, Value>&& p);
 		void erase(const_iterator where);
 		void erase(const_iterator where);
 
 
 		Value& operator[](const Key& key);
 		Value& operator[](const Key& key);
@@ -72,99 +69,73 @@ namespace tinystl {
 
 
 	private:
 	private:
 
 
-		void rehash(size_t nbuckets);
-
 		typedef unordered_hash_node<Key, Value>* pointer;
 		typedef unordered_hash_node<Key, Value>* pointer;
 
 
 		size_t m_size;
 		size_t m_size;
-		tinystl::buffer<pointer, Alloc> m_buckets;
+		buffer<pointer, Alloc> m_buckets;
 	};
 	};
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
-	inline unordered_map<Key, Value, Alloc>::unordered_map()
+	unordered_map<Key, Value, Alloc>::unordered_map()
 		: m_size(0)
 		: m_size(0)
 	{
 	{
 		buffer_init<pointer, Alloc>(&m_buckets);
 		buffer_init<pointer, Alloc>(&m_buckets);
+		buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
 	}
 	}
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
-	inline unordered_map<Key, Value, Alloc>::unordered_map(const unordered_map& other)
+	unordered_map<Key, Value, Alloc>::unordered_map(const unordered_map& other)
 		: m_size(other.m_size)
 		: m_size(other.m_size)
 	{
 	{
 		const size_t nbuckets = (size_t)(other.m_buckets.last - other.m_buckets.first);
 		const size_t nbuckets = (size_t)(other.m_buckets.last - other.m_buckets.first);
 		buffer_init<pointer, Alloc>(&m_buckets);
 		buffer_init<pointer, Alloc>(&m_buckets);
 		buffer_resize<pointer, Alloc>(&m_buckets, nbuckets, 0);
 		buffer_resize<pointer, Alloc>(&m_buckets, nbuckets, 0);
 
 
-		if (other.m_buckets.first) {
-			for (pointer it = *other.m_buckets.first; it; it = it->next) {
-				unordered_hash_node<Key, Value>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, Value>))) unordered_hash_node<Key, Value>(it->first, it->second);
-				newnode->next = newnode->prev = 0;
+		for (pointer it = *other.m_buckets.first; it; it = it->next) {
+			unordered_hash_node<Key, Value>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, Value>))) unordered_hash_node<Key, Value>(it->first, it->second);
+			newnode->next = newnode->prev = 0;
 
 
-				unordered_hash_node_insert(newnode, hash(it->first), m_buckets.first, nbuckets - 1);
-			}
+			unordered_hash_node_insert(newnode, hash(it->first), m_buckets.first, nbuckets - 1);
 		}
 		}
 	}
 	}
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
-	inline unordered_map<Key, Value, Alloc>::unordered_map(unordered_map&& other)
-		: m_size(other.m_size)
-	{
-		buffer_move(&m_buckets, &other.m_buckets);
-		other.m_size = 0;
-	}
-
-	template<typename Key, typename Value, typename Alloc>
-	inline unordered_map<Key, Value, Alloc>::~unordered_map() {
-		if (m_buckets.first != m_buckets.last)
-			clear();
+	unordered_map<Key, Value, Alloc>::~unordered_map() {
+		clear();
 		buffer_destroy<pointer, Alloc>(&m_buckets);
 		buffer_destroy<pointer, Alloc>(&m_buckets);
 	}
 	}
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
-	inline unordered_map<Key, Value, Alloc>& unordered_map<Key, Value, Alloc>::operator=(const unordered_map<Key, Value, Alloc>& other) {
+	unordered_map<Key, Value, Alloc>& unordered_map<Key, Value, Alloc>::operator=(const unordered_map<Key, Value, Alloc>& other) {
 		unordered_map<Key, Value, Alloc>(other).swap(*this);
 		unordered_map<Key, Value, Alloc>(other).swap(*this);
 		return *this;
 		return *this;
 	}
 	}
 
 
-	template<typename Key, typename Value, typename Alloc>
-	inline unordered_map<Key, Value, Alloc>& unordered_map<Key, Value, Alloc>::operator=(unordered_map&& other) {
-		unordered_map(static_cast<unordered_map&&>(other)).swap(*this);
-		return *this;
-	}
-
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
 	inline typename unordered_map<Key, Value, Alloc>::iterator unordered_map<Key, Value, Alloc>::begin() {
 	inline typename unordered_map<Key, Value, Alloc>::iterator unordered_map<Key, Value, Alloc>::begin() {
 		iterator it;
 		iterator it;
-		if (m_buckets.first) {
-			it.node = *m_buckets.first;
-		} else {
-			it.node = nullptr;
-		}
+		it.node = *m_buckets.first;
 		return it;
 		return it;
 	}
 	}
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
 	inline typename unordered_map<Key, Value, Alloc>::iterator unordered_map<Key, Value, Alloc>::end() {
 	inline typename unordered_map<Key, Value, Alloc>::iterator unordered_map<Key, Value, Alloc>::end() {
 		iterator it;
 		iterator it;
-		it.node = nullptr;
+		it.node = 0;
 		return it;
 		return it;
 	}
 	}
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
 	inline typename unordered_map<Key, Value, Alloc>::const_iterator unordered_map<Key, Value, Alloc>::begin() const {
 	inline typename unordered_map<Key, Value, Alloc>::const_iterator unordered_map<Key, Value, Alloc>::begin() const {
 		const_iterator cit;
 		const_iterator cit;
-		if (m_buckets.first) {
-			cit.node = *m_buckets.first;
-		} else {
-			cit.node = nullptr;
-		}
+		cit.node = *m_buckets.first;
 		return cit;
 		return cit;
 	}
 	}
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
 	inline typename unordered_map<Key, Value, Alloc>::const_iterator unordered_map<Key, Value, Alloc>::end() const {
 	inline typename unordered_map<Key, Value, Alloc>::const_iterator unordered_map<Key, Value, Alloc>::end() const {
 		const_iterator cit;
 		const_iterator cit;
-		cit.node = nullptr;
+		cit.node = 0;
 		return cit;
 		return cit;
 	}
 	}
 
 
@@ -180,15 +151,13 @@ namespace tinystl {
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
 	inline void unordered_map<Key, Value, Alloc>::clear() {
 	inline void unordered_map<Key, Value, Alloc>::clear() {
-		if (m_buckets.first) {
-			pointer it = *m_buckets.first;
-			while (it) {
-				const pointer next = it->next;
-				it->~unordered_hash_node<Key, Value>();
-				Alloc::static_deallocate(it, sizeof(unordered_hash_node<Key, Value>));
-
-				it = next;
-			}
+		pointer it = *m_buckets.first;
+		while (it) {
+			const pointer next = it->next;
+			it->~unordered_hash_node<Key, Value>();
+			Alloc::static_deallocate(it, sizeof(unordered_hash_node<Key, Value>));
+
+			it = next;
 		}
 		}
 
 
 		m_buckets.last = m_buckets.first;
 		m_buckets.last = m_buckets.first;
@@ -210,69 +179,37 @@ namespace tinystl {
 		return result;
 		return result;
 	}
 	}
 
 
-	template<typename Key, typename Value, typename Alloc>
-	inline void unordered_map<Key, Value, Alloc>::rehash(size_t nbuckets) {
-		if (!m_buckets.first) return;
-		if (m_size + 1 > 4 * nbuckets) {
-			pointer root = *m_buckets.first;
-
-			const size_t newnbuckets = ((size_t)(m_buckets.last - m_buckets.first) - 1) * 8;
-			m_buckets.last = m_buckets.first;
-			buffer_resize<pointer, Alloc>(&m_buckets, newnbuckets + 1, 0);
-			unordered_hash_node<Key, Value>** buckets = m_buckets.first;
-
-			while (root) {
-				const pointer next = root->next;
-				root->next = root->prev = nullptr;
-				unordered_hash_node_insert(root, hash(root->first), buckets, newnbuckets);
-				root = next;
-			}
-		}
-	}
-
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
 	inline pair<typename unordered_map<Key, Value, Alloc>::iterator, bool> unordered_map<Key, Value, Alloc>::insert(const pair<Key, Value>& p) {
 	inline pair<typename unordered_map<Key, Value, Alloc>::iterator, bool> unordered_map<Key, Value, Alloc>::insert(const pair<Key, Value>& p) {
 		pair<iterator, bool> result;
 		pair<iterator, bool> result;
 		result.second = false;
 		result.second = false;
 
 
 		result.first = find(p.first);
 		result.first = find(p.first);
-		if (result.first.node != nullptr)
+		if (result.first.node != 0)
 			return result;
 			return result;
-
+		
 		unordered_hash_node<Key, Value>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, Value>))) unordered_hash_node<Key, Value>(p.first, p.second);
 		unordered_hash_node<Key, Value>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, Value>))) unordered_hash_node<Key, Value>(p.first, p.second);
-		newnode->next = newnode->prev = nullptr;
+		newnode->next = newnode->prev = 0;
 
 
-		if(!m_buckets.first) buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
 		const size_t nbuckets = (size_t)(m_buckets.last - m_buckets.first);
 		const size_t nbuckets = (size_t)(m_buckets.last - m_buckets.first);
 		unordered_hash_node_insert(newnode, hash(p.first), m_buckets.first, nbuckets - 1);
 		unordered_hash_node_insert(newnode, hash(p.first), m_buckets.first, nbuckets - 1);
 
 
 		++m_size;
 		++m_size;
-		rehash(nbuckets);
-
-		result.first.node = newnode;
-		result.second = true;
-		return result;
-	}
-
-	template<typename Key, typename Value, typename Alloc>
-	inline pair<typename unordered_map<Key, Value, Alloc>::iterator, bool> unordered_map<Key, Value, Alloc>::emplace(pair<Key, Value>&& p) {
-		pair<iterator, bool> result;
-		result.second = false;
-
-		result.first = find(p.first);
-		if (result.first.node != nullptr)
-			return result;
-
-		const size_t keyhash = hash(p.first);
-		unordered_hash_node<Key, Value>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, Value>))) unordered_hash_node<Key, Value>(static_cast<Key&&>(p.first), static_cast<Value&&>(p.second));
-		newnode->next = newnode->prev = 0;
-
-		if (!m_buckets.first) buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
-		const size_t nbuckets = (size_t)(m_buckets.last - m_buckets.first);
-		unordered_hash_node_insert(newnode, keyhash, m_buckets.first, nbuckets - 1);
+		if (m_size + 1 > 4 * nbuckets) {
+			pointer root = *m_buckets.first;
+			
+			const size_t newnbuckets = ((size_t)(m_buckets.last - m_buckets.first) - 1) * 8;
+			m_buckets.last = m_buckets.first;
+			buffer_resize<pointer, Alloc>(&m_buckets, newnbuckets + 1, 0);
+			unordered_hash_node<Key, Value>** buckets = m_buckets.first;
 
 
-		++m_size;
-		rehash(nbuckets);
+			while (root) {
+				const pointer next = root->next;
+				root->next = root->prev = 0;
+				unordered_hash_node_insert(root, hash(root->first), buckets, newnbuckets);
+				root = next;
+			}
+		}
 
 
 		result.first.node = newnode;
 		result.first.node = newnode;
 		result.second = true;
 		result.second = true;
@@ -280,7 +217,7 @@ namespace tinystl {
 	}
 	}
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
-	inline void unordered_map<Key, Value, Alloc>::erase(const_iterator where) {
+	void unordered_map<Key, Value, Alloc>::erase(const_iterator where) {
 		unordered_hash_node_erase(where.node, hash(where->first), m_buckets.first, (size_t)(m_buckets.last - m_buckets.first) - 1);
 		unordered_hash_node_erase(where.node, hash(where->first), m_buckets.first, (size_t)(m_buckets.last - m_buckets.first) - 1);
 
 
 		where->~unordered_hash_node<Key, Value>();
 		where->~unordered_hash_node<Key, Value>();
@@ -289,12 +226,12 @@ namespace tinystl {
 	}
 	}
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
-	inline Value& unordered_map<Key, Value, Alloc>::operator[](const Key& key) {
+	Value& unordered_map<Key, Value, Alloc>::operator[](const Key& key) {
 		return insert(pair<Key, Value>(key, Value())).first->second;
 		return insert(pair<Key, Value>(key, Value())).first->second;
 	}
 	}
 
 
 	template<typename Key, typename Value, typename Alloc>
 	template<typename Key, typename Value, typename Alloc>
-	inline void unordered_map<Key, Value, Alloc>::swap(unordered_map& other) {
+	void unordered_map<Key, Value, Alloc>::swap(unordered_map& other) {
 		size_t tsize = other.m_size;
 		size_t tsize = other.m_size;
 		other.m_size = m_size, m_size = tsize;
 		other.m_size = m_size, m_size = tsize;
 		buffer_swap(&m_buckets, &other.m_buckets);
 		buffer_swap(&m_buckets, &other.m_buckets);

+ 42 - 102
include/tinystl/unordered_set.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,10 +27,9 @@
 #ifndef TINYSTL_UNORDERED_SET_H
 #ifndef TINYSTL_UNORDERED_SET_H
 #define TINYSTL_UNORDERED_SET_H
 #define TINYSTL_UNORDERED_SET_H
 
 
-#include <tinystl/allocator.h>
-#include <tinystl/buffer.h>
-#include <tinystl/hash.h>
-#include <tinystl/hash_base.h>
+#include "buffer.h"
+#include "hash.h"
+#include "hash_base.h"
 
 
 namespace tinystl {
 namespace tinystl {
 
 
@@ -39,11 +38,9 @@ namespace tinystl {
 	public:
 	public:
 		unordered_set();
 		unordered_set();
 		unordered_set(const unordered_set& other);
 		unordered_set(const unordered_set& other);
-		unordered_set(unordered_set&& other);
 		~unordered_set();
 		~unordered_set();
 
 
 		unordered_set& operator=(const unordered_set& other);
 		unordered_set& operator=(const unordered_set& other);
-		unordered_set& operator=(unordered_set&& other);
 
 
 		typedef unordered_hash_iterator<const unordered_hash_node<Key, void> > const_iterator;
 		typedef unordered_hash_iterator<const unordered_hash_node<Key, void> > const_iterator;
 		typedef const_iterator iterator;
 		typedef const_iterator iterator;
@@ -57,7 +54,6 @@ namespace tinystl {
 
 
 		iterator find(const Key& key) const;
 		iterator find(const Key& key) const;
 		pair<iterator, bool> insert(const Key& key);
 		pair<iterator, bool> insert(const Key& key);
-		pair<iterator, bool> emplace(Key&& key);
 		void erase(iterator where);
 		void erase(iterator where);
 		size_t erase(const Key& key);
 		size_t erase(const Key& key);
 
 
@@ -65,80 +61,58 @@ namespace tinystl {
 
 
 	private:
 	private:
 
 
-		void rehash(size_t nbuckets);
-
 		typedef unordered_hash_node<Key, void>* pointer;
 		typedef unordered_hash_node<Key, void>* pointer;
 
 
 		size_t m_size;
 		size_t m_size;
-		tinystl::buffer<pointer, Alloc> m_buckets;
+		buffer<pointer, Alloc> m_buckets;
 	};
 	};
 
 
 	template<typename Key, typename Alloc>
 	template<typename Key, typename Alloc>
-	inline unordered_set<Key, Alloc>::unordered_set()
+	unordered_set<Key, Alloc>::unordered_set()
 		: m_size(0)
 		: m_size(0)
 	{
 	{
 		buffer_init<pointer, Alloc>(&m_buckets);
 		buffer_init<pointer, Alloc>(&m_buckets);
+		buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
 	}
 	}
 
 
 	template<typename Key, typename Alloc>
 	template<typename Key, typename Alloc>
-	inline unordered_set<Key, Alloc>::unordered_set(const unordered_set& other)
+	unordered_set<Key, Alloc>::unordered_set(const unordered_set& other)
 		: m_size(other.m_size)
 		: m_size(other.m_size)
 	{
 	{
 		const size_t nbuckets = (size_t)(other.m_buckets.last - other.m_buckets.first);
 		const size_t nbuckets = (size_t)(other.m_buckets.last - other.m_buckets.first);
 		buffer_init<pointer, Alloc>(&m_buckets);
 		buffer_init<pointer, Alloc>(&m_buckets);
 		buffer_resize<pointer, Alloc>(&m_buckets, nbuckets, 0);
 		buffer_resize<pointer, Alloc>(&m_buckets, nbuckets, 0);
 
 
-		if (other.m_buckets.first) {
-			for (pointer it = *other.m_buckets.first; it; it = it->next) {
-				unordered_hash_node<Key, void>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, void>))) unordered_hash_node<Key, void>(*it);
-				newnode->next = newnode->prev = 0;
-				unordered_hash_node_insert(newnode, hash(it->first), m_buckets.first, nbuckets - 1);
-			}
+		for (pointer it = *other.m_buckets.first; it; it = it->next) {
+			unordered_hash_node<Key, void>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, void>))) unordered_hash_node<Key, void>(*it);
+			newnode->next = newnode->prev = 0;
+			unordered_hash_node_insert(newnode, hash(it->first), m_buckets.first, nbuckets - 1);
 		}
 		}
 	}
 	}
 
 
 	template<typename Key, typename Alloc>
 	template<typename Key, typename Alloc>
-	inline unordered_set<Key, Alloc>::unordered_set(unordered_set&& other)
-		: m_size(other.m_size)
-	{
-		buffer_move(&m_buckets, &other.m_buckets);
-		other.m_size = 0;
-	}
-
-	template<typename Key, typename Alloc>
-	inline unordered_set<Key, Alloc>::~unordered_set() {
-		if (m_buckets.first != m_buckets.last)
-			clear();
+	unordered_set<Key, Alloc>::~unordered_set() {
+		clear();
 		buffer_destroy<pointer, Alloc>(&m_buckets);
 		buffer_destroy<pointer, Alloc>(&m_buckets);
 	}
 	}
 
 
 	template<typename Key, typename Alloc>
 	template<typename Key, typename Alloc>
-	inline unordered_set<Key, Alloc>& unordered_set<Key, Alloc>::operator=(const unordered_set<Key, Alloc>& other) {
+	unordered_set<Key, Alloc>& unordered_set<Key, Alloc>::operator=(const unordered_set<Key, Alloc>& other) {
 		unordered_set<Key, Alloc>(other).swap(*this);
 		unordered_set<Key, Alloc>(other).swap(*this);
 		return *this;
 		return *this;
 	}
 	}
 
 
-	template<typename Key, typename Alloc>
-	inline unordered_set<Key, Alloc>& unordered_set<Key, Alloc>::operator=(unordered_set&& other) {
-		unordered_set(static_cast<unordered_set&&>(other)).swap(*this);
-		return *this;
-	}
-
 	template<typename Key, typename Alloc>
 	template<typename Key, typename Alloc>
 	inline typename unordered_set<Key, Alloc>::iterator unordered_set<Key, Alloc>::begin() const {
 	inline typename unordered_set<Key, Alloc>::iterator unordered_set<Key, Alloc>::begin() const {
-		iterator it;
-		if (m_buckets.first) {
-			it.node = *m_buckets.first;
-		} else {
-			it.node = nullptr;
-		}
-		return it;
+		iterator cit;
+		cit.node = *m_buckets.first;
+		return cit;
 	}
 	}
 
 
 	template<typename Key, typename Alloc>
 	template<typename Key, typename Alloc>
 	inline typename unordered_set<Key, Alloc>::iterator unordered_set<Key, Alloc>::end() const {
 	inline typename unordered_set<Key, Alloc>::iterator unordered_set<Key, Alloc>::end() const {
 		iterator cit;
 		iterator cit;
-		cit.node = nullptr;
+		cit.node = 0;
 		return cit;
 		return cit;
 	}
 	}
 
 
@@ -154,15 +128,13 @@ namespace tinystl {
 
 
 	template<typename Key, typename Alloc>
 	template<typename Key, typename Alloc>
 	inline void unordered_set<Key, Alloc>::clear() {
 	inline void unordered_set<Key, Alloc>::clear() {
-		if (m_buckets.first) {
-			pointer it = *m_buckets.first;
-			while (it) {
-				const pointer next = it->next;
-				it->~unordered_hash_node<Key, void>();
-				Alloc::static_deallocate(it, sizeof(unordered_hash_node<Key, void>));
-
-				it = next;
-			}
+		pointer it = *m_buckets.first;
+		while (it) {
+			const pointer next = it->next;
+			it->~unordered_hash_node<Key, void>();
+			Alloc::static_deallocate(it, sizeof(unordered_hash_node<Key, void>));
+
+			it = next;
 		}
 		}
 
 
 		m_buckets.last = m_buckets.first;
 		m_buckets.last = m_buckets.first;
@@ -177,69 +149,37 @@ namespace tinystl {
 		return result;
 		return result;
 	}
 	}
 
 
-	template<typename Key, typename Alloc>
-	inline void unordered_set<Key, Alloc>::rehash(size_t nbuckets) {
-		if (!m_buckets.first) return;
-		if (m_size + 1 > 4 * nbuckets) {
-			pointer root = *m_buckets.first;
-
-			const size_t newnbuckets = ((size_t)(m_buckets.last - m_buckets.first) - 1) * 8;
-			m_buckets.last = m_buckets.first;
-			buffer_resize<pointer, Alloc>(&m_buckets, newnbuckets + 1, 0);
-			unordered_hash_node<Key, void>** buckets = m_buckets.first;
-
-			while (root) {
-				const pointer next = root->next;
-				root->next = root->prev = nullptr;
-				unordered_hash_node_insert(root, hash(root->first), buckets, newnbuckets);
-				root = next;
-			}
-		}
-	}
-
 	template<typename Key, typename Alloc>
 	template<typename Key, typename Alloc>
 	inline pair<typename unordered_set<Key, Alloc>::iterator, bool> unordered_set<Key, Alloc>::insert(const Key& key) {
 	inline pair<typename unordered_set<Key, Alloc>::iterator, bool> unordered_set<Key, Alloc>::insert(const Key& key) {
 		pair<iterator, bool> result;
 		pair<iterator, bool> result;
 		result.second = false;
 		result.second = false;
 
 
 		result.first = find(key);
 		result.first = find(key);
-		if (result.first.node != nullptr)
+		if (result.first.node != 0)
 			return result;
 			return result;
 
 
 		unordered_hash_node<Key, void>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, void>))) unordered_hash_node<Key, void>(key);
 		unordered_hash_node<Key, void>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, void>))) unordered_hash_node<Key, void>(key);
-		newnode->next = newnode->prev = nullptr;
+		newnode->next = newnode->prev = 0;
 
 
-		if(!m_buckets.first) buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
 		const size_t nbuckets = (size_t)(m_buckets.last - m_buckets.first);
 		const size_t nbuckets = (size_t)(m_buckets.last - m_buckets.first);
 		unordered_hash_node_insert(newnode, hash(key), m_buckets.first, nbuckets - 1);
 		unordered_hash_node_insert(newnode, hash(key), m_buckets.first, nbuckets - 1);
 
 
 		++m_size;
 		++m_size;
-		rehash(nbuckets);
-
-		result.first.node = newnode;
-		result.second = true;
-		return result;
-	}
-
-	template<typename Key, typename Alloc>
-	inline pair<typename unordered_set<Key, Alloc>::iterator, bool> unordered_set<Key, Alloc>::emplace(Key&& key) {
-				pair<iterator, bool> result;
-		result.second = false;
-
-		result.first = find(key);
-		if (result.first.node != nullptr)
-			return result;
-
-		const size_t keyhash = hash(key);
-		unordered_hash_node<Key, void>* newnode = new(placeholder(), Alloc::static_allocate(sizeof(unordered_hash_node<Key, void>))) unordered_hash_node<Key, void>(static_cast<Key&&>(key));
-		newnode->next = newnode->prev = nullptr;
+		if (m_size + 1 > 4 * nbuckets) {
+			pointer root = *m_buckets.first;
 
 
-		if(!m_buckets.first) buffer_resize<pointer, Alloc>(&m_buckets, 9, 0);
-		const size_t nbuckets = (size_t)(m_buckets.last - m_buckets.first);
-		unordered_hash_node_insert(newnode, keyhash, m_buckets.first, nbuckets - 1);
+			const size_t newnbuckets = ((size_t)(m_buckets.last - m_buckets.first) - 1) * 8;
+			m_buckets.last = m_buckets.first;
+			buffer_resize<pointer, Alloc>(&m_buckets, newnbuckets + 1, 0);
+			unordered_hash_node<Key, void>** buckets = m_buckets.first;
 
 
-		++m_size;
-		rehash(nbuckets);
+			while (root) {
+				const pointer next = root->next;
+				root->next = root->prev = 0;
+				unordered_hash_node_insert(root, hash(root->first), buckets, newnbuckets);
+				root = next;
+			}
+		}
 
 
 		result.first.node = newnode;
 		result.first.node = newnode;
 		result.second = true;
 		result.second = true;
@@ -258,7 +198,7 @@ namespace tinystl {
 	template<typename Key, typename Alloc>
 	template<typename Key, typename Alloc>
 	inline size_t unordered_set<Key, Alloc>::erase(const Key& key) {
 	inline size_t unordered_set<Key, Alloc>::erase(const Key& key) {
 		const iterator it = find(key);
 		const iterator it = find(key);
-		if (it.node == nullptr)
+		if (it.node == 0)
 			return 0;
 			return 0;
 
 
 		erase(it);
 		erase(it);

+ 21 - 35
include/tinystl/vector.h

@@ -1,5 +1,5 @@
 /*-
 /*-
- * Copyright 2012-2018 Matthew Endsley
+ * Copyright 2012-1015 Matthew Endsley
  * All rights reserved
  * All rights reserved
  *
  *
  * Redistribution and use in source and binary forms, with or without
  * Redistribution and use in source and binary forms, with or without
@@ -27,25 +27,23 @@
 #ifndef TINYSTL_VECTOR_H
 #ifndef TINYSTL_VECTOR_H
 #define TINYSTL_VECTOR_H
 #define TINYSTL_VECTOR_H
 
 
-#include <tinystl/allocator.h>
-#include <tinystl/buffer.h>
-#include <tinystl/new.h>
-#include <tinystl/stddef.h>
+#include "buffer.h"
+#include "new.h"
+#include "stddef.h"
 
 
 namespace tinystl {
 namespace tinystl {
+
 	template<typename T, typename Alloc = TINYSTL_ALLOCATOR>
 	template<typename T, typename Alloc = TINYSTL_ALLOCATOR>
 	class vector {
 	class vector {
 	public:
 	public:
 		vector();
 		vector();
 		vector(const vector& other);
 		vector(const vector& other);
-		vector(vector&& other);
-		vector(size_t size);
-		vector(size_t size, const T& value);
+		vector(size_t _size);
+		vector(size_t _size, const T& value);
 		vector(const T* first, const T* last);
 		vector(const T* first, const T* last);
 		~vector();
 		~vector();
 
 
 		vector& operator=(const vector& other);
 		vector& operator=(const vector& other);
-		vector& operator=(vector&& other);
 
 
 		void assign(const T* first, const T* last);
 		void assign(const T* first, const T* last);
 
 
@@ -66,7 +64,7 @@ namespace tinystl {
 		void resize(size_t size);
 		void resize(size_t size);
 		void resize(size_t size, const T& value);
 		void resize(size_t size, const T& value);
 		void clear();
 		void clear();
-		void reserve(size_t capacity);
+		void reserve(size_t _capacity);
 
 
 		void push_back(const T& t);
 		void push_back(const T& t);
 		void pop_back();
 		void pop_back();
@@ -119,20 +117,15 @@ namespace tinystl {
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
-	inline vector<T, Alloc>::vector(vector&& other) {
-		buffer_move(&m_buffer, &other.m_buffer);
-	}
-
-	template<typename T, typename Alloc>
-	inline vector<T, Alloc>::vector(size_t size) {
+	inline vector<T, Alloc>::vector(size_t _size) {
 		buffer_init(&m_buffer);
 		buffer_init(&m_buffer);
-		buffer_resize(&m_buffer, size);
+		buffer_resize(&m_buffer, _size);
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
-	inline vector<T, Alloc>::vector(size_t size, const T& value) {
+	inline vector<T, Alloc>::vector(size_t _size, const T& value) {
 		buffer_init(&m_buffer);
 		buffer_init(&m_buffer);
-		buffer_resize(&m_buffer, size, value);
+		buffer_resize(&m_buffer, _size, value);
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
@@ -152,13 +145,6 @@ namespace tinystl {
 		return *this;
 		return *this;
 	}
 	}
 
 
-	template<typename T, typename Alloc>
-	vector<T, Alloc>& vector<T, Alloc>::operator=(vector&& other) {
-		buffer_destroy(&m_buffer);
-		buffer_move(&m_buffer, &other.m_buffer);
-		return *this;
-	}
-
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
 	inline void vector<T, Alloc>::assign(const T* first, const T* last) {
 	inline void vector<T, Alloc>::assign(const T* first, const T* last) {
 		buffer_clear(&m_buffer);
 		buffer_clear(&m_buffer);
@@ -221,13 +207,13 @@ namespace tinystl {
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
-	inline void vector<T, Alloc>::resize(size_t size) {
-		buffer_resize(&m_buffer, size);
+	inline void vector<T, Alloc>::resize(size_t _size) {
+		buffer_resize(&m_buffer, _size);
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
-	inline void vector<T, Alloc>::resize(size_t size, const T& value) {
-		buffer_resize(&m_buffer, size, value);
+	inline void vector<T, Alloc>::resize(size_t _size, const T& value) {
+		buffer_resize(&m_buffer, _size, value);
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
@@ -236,8 +222,8 @@ namespace tinystl {
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
-	inline void vector<T, Alloc>::reserve(size_t capacity) {
-		buffer_reserve(&m_buffer, capacity);
+	inline void vector<T, Alloc>::reserve(size_t _capacity) {
+		buffer_reserve(&m_buffer, _capacity);
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
@@ -292,7 +278,7 @@ namespace tinystl {
 	}
 	}
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
-	inline void vector<T, Alloc>::insert(typename vector::iterator where) {
+	inline void vector<T, Alloc>::insert(iterator where) {
 		buffer_insert(&m_buffer, where, 1);
 		buffer_insert(&m_buffer, where, 1);
 	}
 	}
 
 
@@ -328,9 +314,9 @@ namespace tinystl {
 
 
 	template<typename T, typename Alloc>
 	template<typename T, typename Alloc>
 	template<typename Param>
 	template<typename Param>
-	void vector<T, Alloc>::emplace(typename vector::iterator where, const Param& param) {
+	void vector<T, Alloc>::emplace(iterator where, const Param& param) {
 		buffer_insert(&m_buffer, where, &param, &param + 1);
 		buffer_insert(&m_buffer, where, &param, &param + 1);
 	}
 	}
 }
 }
 
 
-#endif // TINYSTL_VECTOR_H
+#endif

+ 0 - 16
scripts/update_tinystl.sh

@@ -1,16 +0,0 @@
-#!/bin/bash -eux
-
-if [ $# != 1 ]; then
-	echo "Usage: $0 <tinystl-upstream-folder>"
-	exit 1
-fi
-
-SRC_DIR=$1
-DST_DIR="include/tinystl"
-
-pushd $(dirname $0)/..
-
-cp $SRC_DIR/include/TINYSTL/*.h $DST_DIR/
-find $DST_DIR -iname "*.h" -exec sed --in-place 's/<TINYSTL\//<tinystl\//g' {} \;
-
-popd

+ 0 - 91
tests/string_test.cpp

@@ -9,7 +9,6 @@
 #include <bx/handlealloc.h>
 #include <bx/handlealloc.h>
 #include <bx/sort.h>
 #include <bx/sort.h>
 #include <string>
 #include <string>
-#include <tinystl/string.h>
 
 
 bx::AllocatorI* g_allocator;
 bx::AllocatorI* g_allocator;
 
 
@@ -638,93 +637,3 @@ TEST_CASE("0terminated", "[string]")
 	REQUIRE(2 == st.getLength() );
 	REQUIRE(2 == st.getLength() );
 	REQUIRE(st.is0Terminated() );
 	REQUIRE(st.is0Terminated() );
 }
 }
-
-TEST(tinystl_string_constructor) {
-	using tinystl::string;
-	{
-		string s;
-		CHECK( s.size() == 0 );
-	}
-	{
-		string s("hello");
-		CHECK( s.size() == 5 );
-		CHECK( 0 == strcmp(s.c_str(), "hello") );
-	}
-	{
-		string s("hello world", 5);
-		CHECK( s.size() == 5 );
-		CHECK( 0 == strcmp(s.c_str(), "hello") );
-	}
-	{
-		const string other("hello");
-		string s = other;
-
-		CHECK( s.size() == 5 );
-		CHECK( 0 == strcmp(s.c_str(), "hello") );
-	}
-	{
-		string other("hello");
-		string s = std::move(other);
-
-		CHECK( s.size() == 5 );
-		CHECK( 0 == strcmp(s.c_str(), "hello") );
-		CHECK( other.size() == 0 );
-	}
-}
-
-TEST(tinystl_string_assign) {
-	using tinystl::string;
-	{
-		const string other("hello");
-		string s("new");
-		s = other;
-
-		CHECK( s.size() == 5 );
-		CHECK( 0 == strcmp(s.c_str(), "hello") );
-	}
-	{
-		string other("hello");
-		string s("new");
-		s = std::move(other);
-
-		CHECK( s.size() == 5 );
-		CHECK( 0 == strcmp(s.c_str(), "hello") );
-		CHECK( other.size() == 0 );
-	}
-
-	{
-		const string other("hello longer string here");
-		string s("short");
-		s = other;
-
-		CHECK( s.size() == 24 );
-		CHECK( 0 == strcmp(s.c_str(), "hello longer string here") );
-	}
-	{
-		string other("hello longer string here");
-		string s("short");
-		s = std::move(other);
-
-		CHECK( s.size() == 24 );
-		CHECK( 0 == strcmp(s.c_str(), "hello longer string here") );
-		CHECK( other.size() == 0 );
-	}
-
-	{
-		const string other("short");
-		string s("hello longer string here");
-		s = other;
-
-		CHECK( s.size() == 5 );
-		CHECK( 0 == strcmp(s.c_str(), "short") );
-	}
-	{
-		string other("short");
-		string s("hello longer string here");
-		s = std::move(other);
-
-		CHECK( s.size() == 5 );
-		CHECK( 0 == strcmp(s.c_str(), "short") );
-		CHECK( other.size() == 0 );
-	}
-}

+ 0 - 205
tests/unordered_map_test.cpp

@@ -1,205 +0,0 @@
-/*-
-* Copyright 2012-2018 Matthew Endsley
-* All rights reserved
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted providing 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.
-*
-* 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.
-*/
-
-#include "test.h"
-
-#include <tinystl/unordered_map.h>
-#include <tinystl/string.h>
-#include <utility>
-
-template<typename K, typename V>
-static void comparemaps(const tinystl::unordered_map<K, V>& m, const tinystl::unordered_map<K, V>& expected) {
-	CHECK( m.size() == expected.size() );
-
-	typedef typename tinystl::unordered_map<K, V>::const_iterator iterator;
-	for (iterator it = expected.begin(), end = expected.end(); it != end; ++it) {
-		iterator found = m.find((*it).first);
-		CHECK( found != m.end() );
-		CHECK( (*found).second == (*it).second );
-	}
-}
-
-TEST(uomap_constructor) {
-	typedef tinystl::unordered_map<int, int> unordered_map;
-	using tinystl::make_pair;
-
-	unordered_map baseline;
-	comparemaps(baseline, baseline); // test with empty maps
-	baseline.insert(make_pair(5, 1));
-	baseline.insert(make_pair(6, 2));
-	CHECK( 2 == baseline.size() );
-	CHECK( baseline.find(5) != baseline.end() );
-	CHECK( baseline[5] == 1 );
-	CHECK( baseline.find(6) != baseline.end() );
-	CHECK( baseline[6] == 2 );
-	comparemaps(baseline, baseline);
-
-	{
-		unordered_map m;
-
-		CHECK( m.empty() );
-		CHECK( m.size() == 0 );
-	}
-
-	{
-		unordered_map m = baseline;
-
-		comparemaps(m, baseline);
-	}
-
-	{
-		unordered_map other = baseline;
-		unordered_map m = std::move(other);
-
-		comparemaps(m, baseline);
-		CHECK( other.empty() );
-	}
-}
-
-TEST(uomap_assign) {
-	typedef tinystl::unordered_map<int, int> unordered_map;
-	using tinystl::make_pair;
-
-	unordered_map baseline;
-	baseline.insert(make_pair(5, 1));
-	baseline.insert(make_pair(6, 2));
-	CHECK( 2 == baseline.size() );
-	CHECK( baseline.find(5) != baseline.end() );
-	CHECK( baseline[5] == 1 );
-	CHECK( baseline.find(6) != baseline.end() );
-	CHECK( baseline[6] == 2 );
-	comparemaps(baseline, baseline);
-
-	{
-		unordered_map m;
-		m = baseline;
-
-		comparemaps(m, baseline);
-	}
-
-	{
-		unordered_map m;
-		for (int ii = 0; ii != 10; ++ii)
-			m.insert(make_pair(ii, 10*ii));
-
-		m = baseline;
-
-		comparemaps(m, baseline);
-	}
-
-	{
-		unordered_map other = baseline;
-		unordered_map m;
-		m = std::move(other);
-
-		comparemaps(m, baseline);
-		CHECK( other.empty() );
-	}
-
-	{
-		unordered_map other = baseline;
-		unordered_map m;
-		for (int ii = 0; ii != 10; ++ii)
-			m.insert(make_pair(ii, 10*ii));
-
-		m = std::move(other);
-
-		comparemaps(m, baseline);
-		CHECK( other.empty() );
-	}
-}
-
-TEST(uomap_insert) {
-	using tinystl::string;
-	using tinystl::pair;
-	typedef tinystl::unordered_map<string, string> unordered_map;
-	typedef pair<unordered_map::iterator, bool> inspair;
-
-	{
-		unordered_map m;
-		m.insert(make_pair(string("hello"), string("world")));
-		CHECK( m.find("hello") != m.end() );
-	}
-
-	{
-		const pair<string, string> p("hello", "world");
-		unordered_map m;
-		inspair p1 = m.insert(p);
-		CHECK( p1.second );
-		CHECK( (*p1.first).first == tinystl::string("hello") );
-		CHECK( (*p1.first).second == tinystl::string("world") );
-
-		inspair p2 = m.insert(p);
-		CHECK( !p2.second );
-		CHECK( p2.first == p1.first );
-	}
-
-	{
-		unordered_map m;
-		m.emplace(pair<string, string>("hello", "world"));
-
-		CHECK( m.find("hello") != m.end() );
-	}
-
-	{
-		unordered_map m;
-		inspair p1 = m.emplace(pair<string, string>("hello", "world"));
-		CHECK( p1.second );
-		CHECK( (*p1.first).first == tinystl::string("hello") );
-		CHECK( (*p1.first).second == tinystl::string("world") );
-
-		inspair p2 = m.emplace(pair<string, string>("hello", "world"));
-		CHECK( !p2.second );
-		CHECK( p2.first == p1.first );
-	}
-
-	{
-		unordered_map m;
-		pair<string, string> p("hello", "world");
-		m.emplace(std::move(p));
-
-		CHECK( m.find("hello") != m.end() );
-		CHECK( p.first.size() == 0 );
-		CHECK( p.second.size() == 0 );
-	}
-}
-
-TEST(uomap_iterate) {
-	typedef tinystl::unordered_map<size_t, size_t> unordered_map;
-	{
-		unordered_map m;
-		for (size_t i = 0; i < 1000; ++i) {
-			CHECK( m.size() == i );
-			size_t count = 0;
-			for (auto it = m.begin(); it != m.end(); ++it) {
-				count++;
-			}
-			CHECK( count == i );
-
-			m.insert(tinystl::make_pair(17 * i, 101 * i));
-		}
-	}
-}

+ 0 - 191
tests/unordered_set_test.cpp

@@ -1,191 +0,0 @@
-/*-
-* Copyright 2012-2018 Matthew Endsley
-* All rights reserved
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted providing 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.
-*
-* 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.
-*/
-
-#include "test.h"
-
-#include <tinystl/unordered_set.h>
-#include <tinystl/string.h>
-#include <utility>
-
-template<typename T>
-static void comparesets(const tinystl::unordered_set<T>& s, const tinystl::unordered_set<T>& expected) {
-	CHECK( s.size() == expected.size() );
-
-	typedef typename tinystl::unordered_set<T>::const_iterator iterator;
-	for (iterator it = expected.begin(), end = expected.end(); it != end; ++it) {
-		CHECK( s.find(*it) != s.end() );
-	}
-}
-
-TEST(uoset_constructor) {
-	typedef tinystl::unordered_set<int> unordered_set;
-
-	unordered_set baseline;
-	comparesets(baseline, baseline); // test on empty
-	baseline.insert(5);
-	baseline.insert(6);
-	CHECK( 2 == baseline.size() );
-	CHECK( baseline.find(5) != baseline.end() );
-	CHECK( baseline.find(6) != baseline.end() );
-	comparesets(baseline, baseline);
-
-	{
-		unordered_set s;
-
-		CHECK( s.empty() );
-		CHECK( s.size() == 0 );
-	}
-
-	{
-		unordered_set s = baseline;
-
-		comparesets(s, baseline);
-	}
-
-	{
-		unordered_set other = baseline;
-		unordered_set s = std::move(other);
-
-		comparesets(s, baseline);
-		CHECK( other.empty() );
-	}
-}
-
-TEST(uoset_assign) {
-	typedef tinystl::unordered_set<int> unordered_set;
-
-	unordered_set baseline;
-	baseline.insert(5);
-	baseline.insert(6);
-	CHECK( 2 == baseline.size() );
-	CHECK( baseline.find(5) != baseline.end() );
-	CHECK( baseline.find(6) != baseline.end() );
-	comparesets(baseline, baseline);
-
-	{
-		unordered_set s;
-		s = baseline;
-
-		comparesets(s, baseline);
-	}
-
-	{
-		unordered_set s;
-		for (int ii = 0; ii != 10; ++ii)
-			s.insert(ii);
-
-		s = baseline;
-
-		comparesets(s, baseline);
-	}
-
-	{
-		unordered_set other = baseline;
-		unordered_set s;
-		s = std::move(other);
-
-		comparesets(s, baseline);
-		CHECK( other.empty() );
-	}
-
-	{
-		unordered_set other = baseline;
-		unordered_set s;
-		for (int ii = 0; ii != 10; ++ii)
-			s.insert(ii);
-
-		s = std::move(other);
-
-		comparesets(s, baseline);
-		CHECK( other.empty() );
-	}
-}
-
-TEST(uoset_insert) {
-	typedef tinystl::unordered_set<tinystl::string> unordered_set;
-	typedef tinystl::pair<unordered_set::iterator, bool> pair;
-
-	{
-		unordered_set s;
-		s.insert("hello");
-		CHECK( s.find("hello") != s.end() );
-	}
-
-	{
-		unordered_set s;
-		pair p1 = s.insert("hello");
-		CHECK( p1.second );
-		CHECK( (*p1.first) == tinystl::string("hello") );
-
-		pair p2 = s.insert("hello");
-		CHECK( !p2.second );
-		CHECK( p2.first == p1.first );
-	}
-
-	{
-		unordered_set s;
-		s.emplace("hello");
-
-		CHECK( s.find("hello") != s.end() );
-	}
-
-	{
-		unordered_set s;
-		pair p1 = s.emplace("hello");
-		CHECK( p1.second );
-		CHECK( (*p1.first) == tinystl::string("hello") );
-
-		pair p2 = s.emplace("hello");
-		CHECK( !p2.second );
-		CHECK( p2.first == p1.first );
-	}
-
-	{
-		unordered_set s;
-		tinystl::string key("hello");
-		s.emplace(std::move(key));
-
-		CHECK( s.find("hello") != s.end() );
-		CHECK( key.size() == 0 );
-	}
-}
-
-TEST(uoset_iterate) {
-	typedef tinystl::unordered_set<int> unordered_set;
-	{
-		unordered_set s;
-		for (size_t i = 0; i < 1000; ++i) {
-			CHECK( s.size() == i );
-			size_t count = 0;
-			for (auto it = s.begin(); it != s.end(); ++it) {
-				count++;
-			}
-			CHECK( count == i );
-
-			s.insert(17 * i);
-		}
-	}
-}