Why can I use `std::move` without `#include <utility>`?

107 views Asked by At

https://en.cppreference.com/w/cpp/utility/move says that std::move is

Defined in header <utility>

The C++ standard agrees (p. 556).

Still, this compiles in several compilers, including https://www.onlinegdb.com/online_c++_compiler:

#include <memory>

int main() {
    std::unique_ptr<int> ptr1, ptr2;
    ptr2 = std::move(ptr1);
    return 0;
}

Why? Does <memory> include <utility>? Can I rely on that, or is that an implementation detail that may change any time?

0

There are 0 answers