From: Matthias Maier Date: Wed, 27 May 2020 04:04:52 +0000 (-0500) Subject: fix tests with gcc-5, make clang-tidy happy X-Git-Tag: v9.3.0-rc1~1535^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=124c65e5c2f3dfcf491a11abccece2e23ff3d93a;p=dealii.git fix tests with gcc-5, make clang-tidy happy --- 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,