Is it possible to downcast between std::atomic_ref<T> and std::atomic_ref<U> where U is a subclass of T?
I tried the following code which didn't work.
template<typename T>
std::atomic_ref<T> World::getComponentByID(componentInstanceId uuid) const {
static componentTypeId key = stringHash(typeid(T).name());
return components.at(uuid);
}
The template parameter T was position (a subclass of Component). components is a map of componentInstanceIds to Components .
error C2440: 'return': cannot convert from 'const std::atomic_ref<Component>' to 'std::atomic_ref<Position>