I have code like the following that accepts a std::aligned_storage_t
parameter by forwarding reference and is supposed to reinterpret_cast
that into another type and return it to the user.
template <typename AlignedStorageType, typename TypeToReturnAs>
decltype(auto) forward_as_another_type(AlignedStorageType&& storage) {
return *reinterpret_cast<TypeToReturnAs*>(&storage);
}
Is there a good way to maintain the type of reference that storage
is in the return type? For example if storage was an rvalue reference then I would want the return type to also be an rvalue reference.
Aucun commentaire:
Enregistrer un commentaire