According to cppreference, std::construct_at(T*p, Args&&... args)
is equivalent to
return ::new (const_cast<void*>(static_cast<const volatile void*>(p)))
T(std::forward<Args>(args)...);
What is the need/purpose for the cast 'through' const volatile void*
? In other words, why is construct_at
not simply equivalent to
return ::new (static_cast<void*>(p))
T(std::forward<Args>(args)...);
Under which conditions would this latter code cause undesirable behaviour?