std::unique_ptr<T,Deleter>::operator<< (3) - Linux Manuals
std::unique_ptr<T,Deleter>::operator<<: std::unique_ptr<T,Deleter>::operator<<
Command to display std::unique_ptr<T,Deleter>::operator<<
manual in Linux: $ man 3 std::unique_ptr<T,Deleter>::operator<<
NAME
std::unique_ptr<T,Deleter>::operator<< - std::unique_ptr<T,Deleter>::operator<<
Synopsis
template <class CharT, class Traits, class Y, class D>
std::basic_ostream<CharT, Traits>& operator<<(std::basic_ostream<CharT, Traits>& os, (since C++20)
const std::unique_ptr<Y, D>& p);
Inserts the value of the pointer managed by p into the output stream os.
Equivalent to os << p.get().
This overload only participates in overload resolution if os << p.get() is a valid expression.
Parameters
os - a std::basic_ostream to insert p into
p - the pointer to be inserted into os
Return value
os
Notes
If std::unique_ptr<Y, D>::pointer is a pointer to a character type (e.g., when Y is char or char[] or CharT), this may end up calling the overloads_of_operator<<_for_null-terminated_character_strings (causing undefined behavior if the pointer does not in fact point to such a string), rather than the_overload_for_printing_the_value_of_the_pointer_itself.
Example
// Run this code
#include <iostream>
#include <memory>
class Foo {};
int main()
{
auto p = std::make_unique<Foo>();
std::cout << p << '\n';
std::cout << p.get() << '\n';
}
Possible output:
0x6d9028
0x6d9028
See also
returns a pointer to the managed object
get (public member function)
Pages related to std::unique_ptr<T,Deleter>::operator<<
- std::unique_ptr<T,Deleter>::operator= (3) - std::unique_ptr<T,Deleter>::operator=
- std::unique_ptr<T,Deleter>::operator[] (3) - std::unique_ptr<T,Deleter>::operator[]
- std::unique_ptr<T,Deleter>::operatorbool (3) - std::unique_ptr<T,Deleter>::operatorbool
- std::unique_ptr<T,Deleter>::get (3) - std::unique_ptr<T,Deleter>::get
- std::unique_ptr<T,Deleter>::get_deleter (3) - std::unique_ptr<T,Deleter>::get_deleter
- std::unique_ptr<T,Deleter>::release (3) - std::unique_ptr<T,Deleter>::release
- std::unique_ptr<T,Deleter>::reset (3) - std::unique_ptr<T,Deleter>::reset
- std::unique_ptr<T,Deleter>::swap (3) - std::unique_ptr<T,Deleter>::swap
- std::unique_ptr<T,Deleter>::unique_ptr (3) - std::unique_ptr<T,Deleter>::unique_ptr
- std::unique_ptr<T,Deleter>::~unique_ptr (3) - std::unique_ptr<T,Deleter>::~unique_ptr
- std::unique_ptr (3) - std::unique_ptr
- std::unique_copy (3) - std::unique_copy
- std::unique_lock (3) - std::unique_lock
- std::unique_lock<Mutex>::lock (3) - std::unique_lock<Mutex>::lock
- std::unique_lock<Mutex>::mutex (3) - std::unique_lock<Mutex>::mutex
- std::unique_lock<Mutex>::operator= (3) - std::unique_lock<Mutex>::operator=