|
|
@@ -432,7 +432,7 @@ private:
|
|
|
* @return The element converted to the requested type.
|
|
|
*/
|
|
|
template<typename Type, std::size_t Len, std::size_t Align>
|
|
|
-[[nodiscard]] Type any_cast(const basic_any<Len, Align> &data) noexcept {
|
|
|
+[[nodiscard]] std::remove_const_t<Type> any_cast(const basic_any<Len, Align> &data) noexcept {
|
|
|
const auto *const instance = any_cast<std::remove_reference_t<Type>>(&data);
|
|
|
ENTT_ASSERT(instance, "Invalid instance");
|
|
|
return static_cast<Type>(*instance);
|
|
|
@@ -440,7 +440,7 @@ template<typename Type, std::size_t Len, std::size_t Align>
|
|
|
|
|
|
/*! @copydoc any_cast */
|
|
|
template<typename Type, std::size_t Len, std::size_t Align>
|
|
|
-[[nodiscard]] Type any_cast(basic_any<Len, Align> &data) noexcept {
|
|
|
+[[nodiscard]] std::remove_const_t<Type> any_cast(basic_any<Len, Align> &data) noexcept {
|
|
|
// forces const on non-reference types to make them work also with wrappers for const references
|
|
|
auto *const instance = any_cast<std::remove_reference_t<const Type>>(&data);
|
|
|
ENTT_ASSERT(instance, "Invalid instance");
|
|
|
@@ -449,7 +449,7 @@ template<typename Type, std::size_t Len, std::size_t Align>
|
|
|
|
|
|
/*! @copydoc any_cast */
|
|
|
template<typename Type, std::size_t Len, std::size_t Align>
|
|
|
-[[nodiscard]] Type any_cast(basic_any<Len, Align> &&data) noexcept {
|
|
|
+[[nodiscard]] std::remove_const_t<Type> any_cast(basic_any<Len, Align> &&data) noexcept {
|
|
|
if constexpr(std::is_copy_constructible_v<std::remove_cv_t<std::remove_reference_t<Type>>>) {
|
|
|
if(auto *const instance = any_cast<std::remove_reference_t<Type>>(&data); instance) {
|
|
|
return static_cast<Type>(std::move(*instance));
|