GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::unique_ptr::operatorbool(3) C++ Standard Libary std::unique_ptr::operatorbool(3)

std::unique_ptr::operatorbool - std::unique_ptr::operatorbool


explicit operator bool() const noexcept; (since C++11)
(constexpr since C++23)


Checks whether *this owns an object, i.e. whether get() != nullptr.


(none)


true if *this owns an object, false otherwise.

// Run this code


#include <iostream>
#include <memory>


int main()
{
std::unique_ptr<int> ptr(new int(42));


if (ptr) std::cout << "before reset, ptr is: " << *ptr << '\n';
ptr.reset();
ptr ? (std::cout << "after reset, ptr is: " << *ptr)
: (std::cout << "after reset ptr is empty") << '\n';
}


before reset, ptr is: 42
after reset ptr is empty


get returns a pointer to the managed object
(public member function)

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.