mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-13 11:17:06 +07:00
delete uvalue::try_as for rvalue values
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
- fix all includes to work with the library more flexible
|
- fix all includes to work with the library more flexible
|
||||||
- remove ctor_type and dtor_type?
|
- remove ctor_type and dtor_type?
|
||||||
- add variadic variant of invoking to meta_invoke
|
- add variadic variant of invoking to meta_invoke
|
||||||
- delete rvalue uvalue::as/try_as for pointers
|
|
||||||
|
|
||||||
## Version 1.0
|
## Version 1.0
|
||||||
|
|
||||||
|
|||||||
@@ -2496,13 +2496,13 @@ namespace meta_hpp
|
|||||||
template < pointer_kind T >
|
template < pointer_kind T >
|
||||||
[[nodiscard]] T as() const;
|
[[nodiscard]] T as() const;
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
|
||||||
[[nodiscard]] T as() &&;
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] T& as() &;
|
[[nodiscard]] T& as() &;
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] const T& as() const&;
|
[[nodiscard]] const T& as() const&;
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
|
[[nodiscard]] T as() &&;
|
||||||
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] const T&& as() const&&;
|
[[nodiscard]] const T&& as() const&&;
|
||||||
|
|
||||||
template < pointer_kind T >
|
template < pointer_kind T >
|
||||||
@@ -2511,9 +2511,13 @@ namespace meta_hpp
|
|||||||
[[nodiscard]] T try_as() const noexcept;
|
[[nodiscard]] T try_as() const noexcept;
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] T* try_as() noexcept;
|
[[nodiscard]] T* try_as() & noexcept;
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] const T* try_as() const noexcept;
|
[[nodiscard]] const T* try_as() const& noexcept;
|
||||||
|
template < non_pointer_kind T >
|
||||||
|
void try_as() && = delete;
|
||||||
|
template < non_pointer_kind T >
|
||||||
|
void try_as() const&& = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct vtable_t;
|
struct vtable_t;
|
||||||
@@ -10635,17 +10639,6 @@ namespace meta_hpp
|
|||||||
throw_exception(error_code::bad_uvalue_access);
|
throw_exception(error_code::bad_uvalue_access);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
|
||||||
T uvalue::as() && {
|
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
|
||||||
|
|
||||||
if ( T* ptr = try_as<T>() ) {
|
|
||||||
return std::move(*ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw_exception(error_code::bad_uvalue_access);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
T& uvalue::as() & {
|
T& uvalue::as() & {
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
@@ -10668,6 +10661,17 @@ namespace meta_hpp
|
|||||||
throw_exception(error_code::bad_uvalue_access);
|
throw_exception(error_code::bad_uvalue_access);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < non_pointer_kind T >
|
||||||
|
T uvalue::as() && {
|
||||||
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
|
|
||||||
|
if ( T* ptr = try_as<T>() ) {
|
||||||
|
return std::move(*ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw_exception(error_code::bad_uvalue_access);
|
||||||
|
}
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
const T&& uvalue::as() const&& {
|
const T&& uvalue::as() const&& {
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
@@ -10708,7 +10712,7 @@ namespace meta_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
T* uvalue::try_as() noexcept {
|
T* uvalue::try_as() & noexcept {
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
|
|
||||||
using namespace detail;
|
using namespace detail;
|
||||||
@@ -10722,7 +10726,7 @@ namespace meta_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
const T* uvalue::try_as() const noexcept {
|
const T* uvalue::try_as() const& noexcept {
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
|
|
||||||
using namespace detail;
|
using namespace detail;
|
||||||
|
|||||||
@@ -224,9 +224,7 @@ TEST_CASE("meta/meta_utilities/value3/try_as") {
|
|||||||
namespace meta = meta_hpp;
|
namespace meta = meta_hpp;
|
||||||
|
|
||||||
static_assert(std::is_same_v<decltype(std::declval<meta::uvalue&>().try_as<derived>()), derived*>);
|
static_assert(std::is_same_v<decltype(std::declval<meta::uvalue&>().try_as<derived>()), derived*>);
|
||||||
static_assert(std::is_same_v<decltype(std::declval<meta::uvalue&&>().try_as<derived>()), derived*>);
|
|
||||||
static_assert(std::is_same_v<decltype(std::declval<const meta::uvalue&>().try_as<derived>()), const derived*>);
|
static_assert(std::is_same_v<decltype(std::declval<const meta::uvalue&>().try_as<derived>()), const derived*>);
|
||||||
static_assert(std::is_same_v<decltype(std::declval<const meta::uvalue&&>().try_as<derived>()), const derived*>);
|
|
||||||
|
|
||||||
static_assert(std::is_same_v<decltype(std::declval<meta::uvalue&>().try_as<derived*>()), derived*>);
|
static_assert(std::is_same_v<decltype(std::declval<meta::uvalue&>().try_as<derived*>()), derived*>);
|
||||||
static_assert(std::is_same_v<decltype(std::declval<meta::uvalue&&>().try_as<derived*>()), derived*>);
|
static_assert(std::is_same_v<decltype(std::declval<meta::uvalue&&>().try_as<derived*>()), derived*>);
|
||||||
|
|||||||
@@ -87,13 +87,13 @@ namespace meta_hpp
|
|||||||
template < pointer_kind T >
|
template < pointer_kind T >
|
||||||
[[nodiscard]] T as() const;
|
[[nodiscard]] T as() const;
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
|
||||||
[[nodiscard]] T as() &&;
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] T& as() &;
|
[[nodiscard]] T& as() &;
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] const T& as() const&;
|
[[nodiscard]] const T& as() const&;
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
|
[[nodiscard]] T as() &&;
|
||||||
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] const T&& as() const&&;
|
[[nodiscard]] const T&& as() const&&;
|
||||||
|
|
||||||
template < pointer_kind T >
|
template < pointer_kind T >
|
||||||
@@ -102,9 +102,13 @@ namespace meta_hpp
|
|||||||
[[nodiscard]] T try_as() const noexcept;
|
[[nodiscard]] T try_as() const noexcept;
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] T* try_as() noexcept;
|
[[nodiscard]] T* try_as() & noexcept;
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
[[nodiscard]] const T* try_as() const noexcept;
|
[[nodiscard]] const T* try_as() const& noexcept;
|
||||||
|
template < non_pointer_kind T >
|
||||||
|
void try_as() && = delete;
|
||||||
|
template < non_pointer_kind T >
|
||||||
|
void try_as() const&& = delete;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct vtable_t;
|
struct vtable_t;
|
||||||
|
|||||||
@@ -442,17 +442,6 @@ namespace meta_hpp
|
|||||||
throw_exception(error_code::bad_uvalue_access);
|
throw_exception(error_code::bad_uvalue_access);
|
||||||
}
|
}
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
|
||||||
T uvalue::as() && {
|
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
|
||||||
|
|
||||||
if ( T* ptr = try_as<T>() ) {
|
|
||||||
return std::move(*ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
throw_exception(error_code::bad_uvalue_access);
|
|
||||||
}
|
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
T& uvalue::as() & {
|
T& uvalue::as() & {
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
@@ -475,6 +464,17 @@ namespace meta_hpp
|
|||||||
throw_exception(error_code::bad_uvalue_access);
|
throw_exception(error_code::bad_uvalue_access);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template < non_pointer_kind T >
|
||||||
|
T uvalue::as() && {
|
||||||
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
|
|
||||||
|
if ( T* ptr = try_as<T>() ) {
|
||||||
|
return std::move(*ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw_exception(error_code::bad_uvalue_access);
|
||||||
|
}
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
const T&& uvalue::as() const&& {
|
const T&& uvalue::as() const&& {
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
@@ -515,7 +515,7 @@ namespace meta_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
T* uvalue::try_as() noexcept {
|
T* uvalue::try_as() & noexcept {
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
|
|
||||||
using namespace detail;
|
using namespace detail;
|
||||||
@@ -529,7 +529,7 @@ namespace meta_hpp
|
|||||||
}
|
}
|
||||||
|
|
||||||
template < non_pointer_kind T >
|
template < non_pointer_kind T >
|
||||||
const T* uvalue::try_as() const noexcept {
|
const T* uvalue::try_as() const& noexcept {
|
||||||
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
static_assert(std::is_same_v<T, std::decay_t<T>>);
|
||||||
|
|
||||||
using namespace detail;
|
using namespace detail;
|
||||||
|
|||||||
Reference in New Issue
Block a user