I've just stumbled upon the std::alignment_of type trait, and its soon-to-be friend std::alignment_of_v. They seem to have been specifically designed to be equivalent to a plain call to alignof, and the future addition of the _v helper indicates that it's not just a legacy bit.
What is the use of std::alignment_of (_v), when we have alignof ?
They are almost completely redundant. As @Revolver noted, they were introduced in different papers, and
alignment_ofcomes fromboostnearly verbatim.But that does not mean the trait is useless.
A
template<class...>classcan be passed to othertemplates and used with metaprogramming. Operators likealignofcannot: you would have to write thetemplate<class>class alignment_ofbefore you could pass it to metaprogramming facilities.Now the same could be said of
sizeofneeding astd::size_of<class>template....
The addition of
_vwas because they swept every::valueintegral_constant-type template instdand added a_vvariable template. Considering which ones where worthy and which not would be bikeshed painting and nearly pointless: it is easier to do every one than spend effort picking the worthy ones to do. It being done is not evidence the feature is not obsolete.