From 124c65e5c2f3dfcf491a11abccece2e23ff3d93a Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Tue, 26 May 2020 23:04:52 -0500 Subject: [PATCH] fix tests with gcc-5, make clang-tidy happy --- include/deal.II/base/thread_local_storage.h | 41 +++++++++++---------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/include/deal.II/base/thread_local_storage.h b/include/deal.II/base/thread_local_storage.h index e9f1d778f5..2c96321bb3 100644 --- a/include/deal.II/base/thread_local_storage.h +++ b/include/deal.II/base/thread_local_storage.h @@ -21,10 +21,11 @@ # include +# include # include # include # include - +# include DEAL_II_NAMESPACE_OPEN @@ -41,20 +42,27 @@ namespace Threads namespace { /* - * Workaround: The standard unfortunately has a flaw in the type traits - * when it comes to std::is_copy_constructible and a std::vector - * containing non-copyable objects T. The type trait is true even - * though any attempted invocation leads to a compilation error. Work - * around this issue by removing the "std::vector" container from the - * type trait. + * Workaround: The standard unfortunately has an unfortunate design + * "flaw" in the std::is_copy_constructible type trait + * when it comes to STL containers and containing non-copyable objects + * T. The type trait is true even though any attempted invocation leads + * to a compilation error. Work around this issue by unpacking some + * commonly used containers: */ template - struct unpack_vector + struct unpack_container { using type = T; }; + template - struct unpack_vector> + struct unpack_container> + { + using type = T; + }; + + template + struct unpack_container> { using type = T; }; @@ -92,7 +100,7 @@ namespace Threads class ThreadLocalStorage { static_assert( - std::is_copy_constructible::type>::value || + std::is_copy_constructible::type>::value || std::is_default_constructible::value, "The stored type must be either copyable, or default constructible"); @@ -101,7 +109,7 @@ namespace Threads * Default constructor. Initialize each thread local object using its * default constructor. */ - ThreadLocalStorage(); + ThreadLocalStorage() = default; /** * A kind of copy constructor. Initializes an internal exemplar by the @@ -127,7 +135,7 @@ namespace Threads * Move constructor. Copies the internal state over from the given * object. */ - ThreadLocalStorage(ThreadLocalStorage &&t) = default; + ThreadLocalStorage(ThreadLocalStorage &&t) noexcept = default; /** * Return a reference to the data stored by this object for the current @@ -246,11 +254,6 @@ namespace Threads { // ----------------- inline and template functions -------------------------- - template - inline ThreadLocalStorage::ThreadLocalStorage() - {} - - template inline ThreadLocalStorage::ThreadLocalStorage(const T &t) : exemplar(std::make_shared(t)) @@ -274,7 +277,7 @@ namespace Threads */ template typename std::enable_if_t< - std::is_copy_constructible::type>::value, + std::is_copy_constructible::type>::value, T &> construct_element(std::map & data, const std::thread::id & id, @@ -290,7 +293,7 @@ namespace Threads template typename std::enable_if_t< - !std::is_copy_constructible::type>::value, + !std::is_copy_constructible::type>::value, T &> construct_element(std::map &data, const std::thread::id & id, -- 2.39.5