diff options
author | Alex Zolotarev <alex@maps.me> | 2014-10-14 13:14:55 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 02:30:57 +0300 |
commit | 0ddcff0b07566260e1e00990f70555110fb5cfa7 (patch) | |
tree | 32d542f1b9d9f6dcdc4e800b4ac5b3d6ee62b2c8 /std | |
parent | 9ad4f6585c45443815b7ab9a691a7c47eefe6012 (diff) |
[msvc][win] Fixed compilation issues
Diffstat (limited to 'std')
-rw-r--r-- | std/algorithm.hpp | 46 | ||||
-rw-r--r-- | std/bind.hpp | 2 | ||||
-rw-r--r-- | std/common_defines.hpp | 6 | ||||
-rw-r--r-- | std/function.hpp | 2 | ||||
-rw-r--r-- | std/shared_ptr.hpp | 2 | ||||
-rw-r--r-- | std/systime.hpp | 4 | ||||
-rw-r--r-- | std/unordered_map.hpp | 5 | ||||
-rw-r--r-- | std/unordered_set.hpp | 5 | ||||
-rw-r--r-- | std/weak_ptr.hpp | 2 | ||||
-rw-r--r-- | std/windows.hpp | 29 |
10 files changed, 62 insertions, 41 deletions
diff --git a/std/algorithm.hpp b/std/algorithm.hpp index 986607a72d..761271018b 100644 --- a/std/algorithm.hpp +++ b/std/algorithm.hpp @@ -31,7 +31,53 @@ using std::replace; using std::reverse; using std::set_union; using std::set_intersection; +// Bug workaround, see http://connect.microsoft.com/VisualStudio/feedbackdetail/view/840578/algorithm-possible-c-compiler-bug-when-using-std-set-difference-with-custom-comperator +#ifdef _MSC_VER +namespace vs_bug +{ +template<class InputIt1, class InputIt2, class OutputIt, class Compare> +OutputIt set_difference( InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first, Compare comp) +{ + while (first1 != last1) + { + if (first2 == last2) + return std::copy(first1, last1, d_first); + if (comp(*first1, *first2)) + *d_first++ = *first1++; + else + { + if (!comp(*first2, *first1)) + ++first1; + ++first2; + } + } + return d_first; +} + +template<class InputIt1, class InputIt2, class OutputIt> +OutputIt set_difference(InputIt1 first1, InputIt1 last1, InputIt2 first2, InputIt2 last2, OutputIt d_first) +{ + while (first1 != last1) + { + if (first2 == last2) + return std::copy(first1, last1, d_first); + + if (*first1 < *first2) + *d_first++ = *first1++; + else + { + if (! (*first2 < *first1)) + ++first1; + ++first2; + } + } + return d_first; +} + +} // namespace vc_bug +#else using std::set_difference; +#endif using std::set_symmetric_difference; using std::transform; using std::push_heap; diff --git a/std/bind.hpp b/std/bind.hpp index 07c5abfc54..deda8a0113 100644 --- a/std/bind.hpp +++ b/std/bind.hpp @@ -6,7 +6,7 @@ #undef new #endif -#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#ifdef CPP11_IS_SUPPORTED #include <functional> using std::bind; diff --git a/std/common_defines.hpp b/std/common_defines.hpp index 944232a755..7486fa6389 100644 --- a/std/common_defines.hpp +++ b/std/common_defines.hpp @@ -1,4 +1,10 @@ #pragma once +#ifndef _USE_MATH_DEFINES #define _USE_MATH_DEFINES +#endif #define _FILE_OFFSET_BITS 64 + +#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(_MSC_VER) + #define CPP11_IS_SUPPORTED +#endif diff --git a/std/function.hpp b/std/function.hpp index 9c3f6d9a4c..d43499e7bc 100644 --- a/std/function.hpp +++ b/std/function.hpp @@ -5,7 +5,7 @@ #undef new #endif -#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#ifdef CPP11_IS_SUPPORTED #include <functional> using std::function; diff --git a/std/shared_ptr.hpp b/std/shared_ptr.hpp index d05e4e0b25..1fefc06f5d 100644 --- a/std/shared_ptr.hpp +++ b/std/shared_ptr.hpp @@ -5,7 +5,7 @@ #undef new #endif -#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#ifdef CPP11_IS_SUPPORTED #include <memory> using std::shared_ptr; diff --git a/std/systime.hpp b/std/systime.hpp index c535b83e50..e32d8c9f84 100644 --- a/std/systime.hpp +++ b/std/systime.hpp @@ -2,6 +2,7 @@ #include "common_defines.hpp" #include "target_os.hpp" +#include "ctime.hpp" #ifdef new #undef new @@ -10,6 +11,9 @@ // for gettimeofday and GetSystemTimeAsFileTime #ifdef OMIM_OS_WINDOWS #include "windows.hpp" + #ifdef OMIM_OS_WINDOWS_MINGW + #define gettimeofday mingw_gettimeofday + #endif #else #include <sys/time.h> #endif diff --git a/std/unordered_map.hpp b/std/unordered_map.hpp index 19e9588b4c..e6b9fb90f1 100644 --- a/std/unordered_map.hpp +++ b/std/unordered_map.hpp @@ -5,11 +5,6 @@ #undef new #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1600) - // to avoid compilation errors on VS2010 - #define BOOST_NO_0X_HDR_TYPEINDEX -#endif - #include <boost/unordered_map.hpp> using boost::unordered_map; using boost::unordered_multimap; diff --git a/std/unordered_set.hpp b/std/unordered_set.hpp index c0a69d9eca..2377ed7f2a 100644 --- a/std/unordered_set.hpp +++ b/std/unordered_set.hpp @@ -5,11 +5,6 @@ #undef new #endif -#if defined(_MSC_VER) && (_MSC_VER >= 1600) - // to avoid compilation errors on VS2010 - #define BOOST_NO_0X_HDR_TYPEINDEX -#endif - #include <boost/unordered_set.hpp> using boost::unordered_set; diff --git a/std/weak_ptr.hpp b/std/weak_ptr.hpp index 842e086efd..e7cba78b95 100644 --- a/std/weak_ptr.hpp +++ b/std/weak_ptr.hpp @@ -5,7 +5,7 @@ #undef new #endif -#if (__cplusplus > 199711L) || defined(__GXX_EXPERIMENTAL_CXX0X__) +#ifdef CPP11_IS_SUPPORTED #include <memory> using std::weak_ptr; diff --git a/std/windows.hpp b/std/windows.hpp index 714c555889..2003a55ebf 100644 --- a/std/windows.hpp +++ b/std/windows.hpp @@ -3,36 +3,11 @@ #include "target_os.hpp" #ifdef OMIM_OS_WINDOWS -// These defines are moved to common.pri because -// they should be equal for all libraries, even for 3party ones - -//#ifdef _WIN32_WINNT -// #undef _WIN32_WINNT -//#endif -//#define _WIN32_WINNT 0x0501 - -//#ifdef WINVER -// #undef WINVER -//#endif -//#define WINVER 0x0501 - -//#ifndef WIN32_LEAN_AND_MEAN -// #define WIN32_LEAN_AND_MEAN 1 -//#endif - -//#ifdef _WIN32_IE -// #undef _WIN32_IE -//#endif -//#define _WIN32_IE 0x0501 - -//#ifdef NTDDI_VERSION -// #undef NTDDI_VERSION -//#endif -//#define NTDDI_VERSION 0x05010000 - #include <windows.h> #undef min #undef max +//#undef far +//#undef near #endif // OMIM_OS_WINDOWS |