diff options
author | Valeriy Kopylov <valery.kopylov@akvelon.com> | 2014-11-17 18:36:10 +0300 |
---|---|---|
committer | Valeriy Kopylov <valery.kopylov@akvelon.com> | 2014-11-17 18:36:10 +0300 |
commit | 58ce1c8dcbb336785617caa1d6842f07f2ae20b3 (patch) | |
tree | 9eeede32f9ba2f6cd447ba238801935bb96edaf7 /Rx/v2/src/rxcpp/rx-util.hpp | |
parent | f62887a969186c2a2d1671a89a63cabe73d7add0 (diff) | |
download | RxCpp-58ce1c8dcbb336785617caa1d6842f07f2ae20b3.tar.gz |
Disable clang optimization on extract_list_front() for OSX
Diffstat (limited to 'Rx/v2/src/rxcpp/rx-util.hpp')
-rw-r--r-- | Rx/v2/src/rxcpp/rx-util.hpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/Rx/v2/src/rxcpp/rx-util.hpp b/Rx/v2/src/rxcpp/rx-util.hpp index 7a83b7d..172720c 100644 --- a/Rx/v2/src/rxcpp/rx-util.hpp +++ b/Rx/v2/src/rxcpp/rx-util.hpp @@ -593,15 +593,24 @@ struct list_not_empty { }; struct extract_list_front { + // Clang optimisation loses moved list.front() value after list.pop_front(), so optimization must be switched off. template<class T> -#if defined(__clang__) +#if defined(__clang__) && defined(__linux__) + // Clang on Linux has an attribute to forbid optimization __attribute__((optnone)) #endif auto operator()(std::list<T>& list) const -> decltype(std::move(list.front())) { +#if defined(__clang__) && !defined(__linux__) + // Clang on OSX doesn't support the attribute + volatile auto val = std::move(list.front()); + list.pop_front(); + return std::move(const_cast<T&>(val)); +#else auto val = std::move(list.front()); list.pop_front(); return std::move(val); +#endif } }; |