浏览代码

Added mapRemove.

Branimir Karadžić 9 年之前
父节点
当前提交
80dd79936a
共有 3 个文件被更改,包括 38 次插入1 次删除
  1. 29 0
      include/bx/maputil.h
  2. 3 0
      include/tinystl/hash_base.h
  3. 6 1
      scripts/toolchain.lua

+ 29 - 0
include/bx/maputil.h

@@ -24,6 +24,35 @@ namespace bx
 		typename MapType::value_type pair(_key, _value);
 		return _map.insert(it, pair);
 	}
+
+	template<typename MapType>
+	bool mapRemove(MapType& _map, const typename MapType::value_type::first_type& _first)
+	{
+		typename MapType::const_iterator it = _map.find(_first);
+		if (it != _map.end() )
+		{
+			_map.erase(it);
+			return true;
+		}
+
+		return false;
+	}
+
+	template<typename MapType>
+	bool mapRemove(MapType& _map, const typename MapType::value_type::second_type& _second)
+	{
+		for (typename MapType::const_iterator it = _map.begin(), itEnd = _map.end(); it != itEnd; ++it)
+		{
+			if (it->second == _second)
+			{
+				_map.erase(it);
+				return true;
+			}
+		}
+
+		return false;
+	}
+
 } // namespace bx
 
 #endif // BX_MAPUTIL_H_HEADER_GUARD

+ 3 - 0
include/tinystl/hash_base.h

@@ -33,6 +33,9 @@ namespace tinystl {
 
 	template<typename Key, typename Value>
 	struct pair {
+		typedef Key first_type;
+		typedef Value second_type;
+
 		pair();
 		pair(const Key& key, const Value& value);
 

+ 6 - 1
scripts/toolchain.lua

@@ -47,6 +47,7 @@ function toolchain(_buildDir, _libDir)
 		allowed = {
 			{ "vs2012-clang",  "Clang 3.6"                       },
 			{ "vs2013-clang",  "Clang 3.6"                       },
+			{ "vs2015-clang",  "Clang 3.9"                       },
 			{ "vs2012-xp",     "Visual Studio 2012 targeting XP" },
 			{ "vs2013-xp",     "Visual Studio 2013 targeting XP" },
 			{ "vs2015-xp",     "Visual Studio 2015 targeting XP" },
@@ -339,7 +340,11 @@ function toolchain(_buildDir, _libDir)
 	elseif _ACTION == "vs2012" or _ACTION == "vs2013" or _ACTION == "vs2015" then
 
 		if (_ACTION .. "-clang") == _OPTIONS["vs"] then
-			premake.vstudio.toolset = ("LLVM-" .. _ACTION)
+			if "vs2015-clang" == _OPTIONS["vs"] then
+				premake.vstudio.toolset = ("LLVM-vs2014")
+			else
+				premake.vstudio.toolset = ("LLVM-" .. _ACTION)
+			end
 			location (path.join(_buildDir, "projects", _ACTION .. "-clang"))
 
 		elseif "winphone8" == _OPTIONS["vs"] then