I'm concerned that in kernel land I will not have access to things like std::move
, std::forward
, std::initializer_list
, etc. While some of these features are built into the language, they still require the appropriate headers and library implementation. Is the following sufficient to take advantage of move semantics, or do I need to go the full nine yards and port a C++ library?
template <typename T>
typename remove_reference<T>::type&& move(T&& arg)
{
return static_cast<typename remove_reference<T>::type&&>(arg);
}
<initializer_list>
(and it's not something that you can code up yourself since it's intimately tied to the compiler implementation).std::move
andstd::forward
you may have to code up yourself, but they are just prettified casts. Move semantics needs (1) compiler support and (2) move-aware types. If you are using a C++03std::vector
implementation, you won't get move semantics even withstd::move
and a C++11 compiler. – Oversewstd::...
– Affirm