meta::copy_constructible

Defined in header <mgs/meta/concepts/copy_constructible.hpp>.

template <typename T>
concept copy_constructible =
  meta::move_constructible<T> &&
  meta::constructible_from<T, T&> && meta::convertible_to<T&, T> &&
  meta::constructible_from<T, T const&> && meta::convertible_to<T const&, T> &&
  meta::constructible_from<T, T const> && meta::convertible_to<T const, T>;

Pre-C++20 implementation of the std::copy_constructible concept.


Concept emulation

namespace mgs {
namespace meta {

template <typename T>
struct is_copy_constructible { /* ... */ };

template <typename T>
constexpr auto is_copy_constructible_v = is_copy_constructible<T>::value;

template <typename T,
          typename = std::enable_if_t<is_copy_constructible_v<T>>>
using copy_constructible = T;

} // namespace meta
} // namespace mgs

Example

#include <mgs/meta/concepts/copy_constructible.hpp>

using namespace mgs::meta;

static_assert(is_copy_constructible_v<int>, "");
static_assert(!is_copy_constructible_v<char[]>, "");