fix tls's defect

This commit is contained in:
mutouyun 2019-09-21 14:21:57 +00:00
parent c8cedf11cf
commit 659989fd31
3 changed files with 4 additions and 4 deletions

2
include/tls_pointer.h Normal file → Executable file
View File

@ -61,7 +61,7 @@ public:
template <typename... P>
T* create(P&&... params) {
thread_local auto ptr = static_cast<T*>(get(key_));
auto ptr = static_cast<T*>(get(key_));
if (ptr == nullptr) {
ptr = new T(std::forward<P>(params)...);
if (!set(key_, ptr)) {

2
src/ipc.cpp Normal file → Executable file
View File

@ -5,7 +5,7 @@
#include <algorithm>
#include <utility>
#include <atomic>
#include <type_traits>
#include <type_traits> // aligned_storage_t
#include <string>
#include <vector>

4
src/platform/detail.h Normal file → Executable file
View File

@ -117,7 +117,7 @@ constexpr decltype(auto) static_switch(std::size_t /*i*/, std::index_sequence<>,
template <typename F, typename D, std::size_t N, std::size_t...I>
constexpr decltype(auto) static_switch(std::size_t i, std::index_sequence<N, I...>, F&& f, D&& def) {
return (i == N) ? std::forward<F>(f)(std::integral_constant<size_t, N>{}) :
return (i == N) ? std::forward<F>(f)(std::integral_constant<std::size_t, N>{}) :
static_switch(i, std::index_sequence<I...>{}, std::forward<F>(f), std::forward<D>(def));
}
@ -128,7 +128,7 @@ constexpr decltype(auto) static_switch(std::size_t i, F&& f, D&& def) {
template <typename F, std::size_t...I>
IPC_CONSTEXPR_ void static_for(std::index_sequence<I...>, F&& f) {
IPC_UNUSED_ auto expand = { (std::forward<F>(f)(std::integral_constant<size_t, I>{}), 0)... };
IPC_UNUSED_ auto expand = { (std::forward<F>(f)(std::integral_constant<std::size_t, I>{}), 0)... };
}
template <std::size_t N, typename F>