SpECTRE Documentation Coverage Report
Current view: top level - Utilities/TypeTraits - CanBeCopyConstructed.hpp Hit Total Coverage
Commit: 3c072f0ce967e2e56649d3fa12aa2a0e4fe2a42e Lines: 1 3 33.3 %
Date: 2024-04-23 20:50:18
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <type_traits>
       7             : 
       8             : namespace tt {
       9             : /// @{
      10             : /*!
      11             :  * \ingroup TypeTraitsGroup
      12             :  * \brief Check if `T` is copy constructible
      13             :  *
      14             :  * The STL `std::is_copy_constructible` does not work as expected with some
      15             :  * types, such as `std::unordered_map`. This is because
      16             :  * `std::is_copy_constructible` only checks that the copy construction call is
      17             :  * well-formed, not that it could actually be done in practice. To get around
      18             :  * this for containers we check that `T::value_type` is also copy constructible.
      19             :  */
      20             : template <typename T, typename = void>
      21           1 : struct can_be_copy_constructed : std::is_copy_constructible<T> {};
      22             : 
      23             : /// \cond
      24             : template <typename T>
      25             : struct can_be_copy_constructed<T, std::void_t<typename T::value_type>>
      26             :     : std::bool_constant<std::is_copy_constructible_v<T> and
      27             :                          std::is_copy_constructible_v<typename T::value_type>> {
      28             : };
      29             : /// \endcond
      30             : 
      31             : template <typename T>
      32           0 : constexpr bool can_be_copy_constructed_v = can_be_copy_constructed<T>::value;
      33             : /// @}
      34             : }  // namespace tt

Generated by: LCOV version 1.14