From 32cb97237e7691d31977ab503c6ea4511e8eb3a8 Mon Sep 17 00:00:00 2001 From: Daniel Wilhelm Date: Fri, 18 Apr 2014 17:18:53 +0200 Subject: 5.0 --- zen/stl_tools.h | 40 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 3 deletions(-) (limited to 'zen/stl_tools.h') diff --git a/zen/stl_tools.h b/zen/stl_tools.h index 96101821..03a10f96 100644 --- a/zen/stl_tools.h +++ b/zen/stl_tools.h @@ -2,13 +2,21 @@ // * This file is part of the zenXML project. It is distributed under the * // * Boost Software License, Version 1.0. See accompanying file * // * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt. * -// * Copyright (C) 2011 ZenJu (zhnmju123 AT gmx.de) * +// * Copyright (C) ZenJu (zhnmju123 AT gmx DOT de) - All Rights Reserved * // ************************************************************************** #ifndef STL_TOOLS_HEADER_84567184321434 #define STL_TOOLS_HEADER_84567184321434 -//no need to drag in any STL includes +#include +#if defined _MSC_VER && _MSC_VER <= 1600 +#include +#include +#else +#include +#include +#endif + //enhancements for @@ -36,8 +44,12 @@ template BidirectionalIterator1 search_last(BidirectionalIterator1 first1, BidirectionalIterator1 last1, BidirectionalIterator2 first2, BidirectionalIterator2 last2); +//hash container: proper name + mitigate MSVC performance bug +template class hash_set; +template class hash_map; - +template +std::unique_ptr make_unique(Arg1&& arg1); //should eventually make it into the std at some time @@ -138,6 +150,28 @@ BidirectionalIterator1 search_last(const BidirectionalIterator1 first1, Bidirect --last1; } } + + +#if defined _MSC_VER && _MSC_VER <= 1600 //VS2010 performance bug in std::unordered_set<>: http://drdobbs.com/blogs/cpp/232200410 -> should be fixed in VS11 +template class hash_set : public std::set {}; +template class hash_map : public std::map {}; +#else +template class hash_set : public std::unordered_set {}; +template class hash_map : public std::unordered_map {}; +#endif + +//as long as variadic templates are not available in MSVC +template inline std::unique_ptr make_unique(Arg1&& arg1) { return std::unique_ptr(new T(std::forward(arg1))); } +template inline std::unique_ptr make_unique(Arg1&& arg1, Arg2&& arg2) { return std::unique_ptr(new T(std::forward(arg1), std::forward(arg2))); } +template inline std::unique_ptr make_unique(Arg1&& arg1, Arg2&& arg2, Arg3&& arg3) { return std::unique_ptr(new T(std::forward(arg1), std::forward(arg2), std::forward(arg3))); } +template inline std::unique_ptr make_unique(Arg1&& arg1, Arg2&& arg2, Arg3&& arg3, Arg4&& arg4) { return std::unique_ptr(new T(std::forward(arg1), std::forward(arg2), std::forward(arg3), std::forward(arg4))); } +template inline std::unique_ptr make_unique(Arg1&& arg1, Arg2&& arg2, Arg3&& arg3, Arg4&& arg4, Arg5&& arg5) { return std::unique_ptr(new T(std::forward(arg1), std::forward(arg2), std::forward(arg3), std::forward(arg4), std::forward(arg5))); } + +//template inline +//std::unique_ptr make_unique(Args&& ...args) +//{ +// return std::unique_ptr(new T( std::forward(args)... )); +//} } #endif //STL_TOOLS_HEADER_84567184321434 -- cgit