SpECTRE
v2021.04.06
Documentation
Introduction
Releases
Installation
User Tutorials
Dev Guide
Code of Conduct
Contributing Guide
Code Reference
Topics
Namespaces
Files
Bibliography
View on GitHub
src
Utilities
TypeTraits
CanBeCopyConstructed.hpp
1
// 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
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
constexpr
bool
can_be_copy_constructed_v = can_be_copy_constructed<T>::value;
33
// @}
34
}
// namespace tt
std::bool_constant
tt::can_be_copy_constructed
Check if T is copy constructible.
Definition:
CanBeCopyConstructed.hpp:21
std::is_copy_constructible
tt
Definition:
TensorExpression.hpp:141
type_traits
© Copyright 2017 - 2021
SXS Collaboration
,
Distributed under the
MIT License