nothrow Questions

1

For the new operator, we have the std::nothrow version: std::unique_ptr<T> p = new(std::nothrow) T(); Do we have something like this for the std::make_shared or std::make_unique?
Peppermint asked 18/7, 2019 at 10:20

3

Solved

Can std::string s; throw under any circumstances? Is this regulated by the standard (interested in C++03, in case there are differences)?
Tritanopia asked 20/1, 2013 at 2:41

4

The "placement new" operator is declared as such: void* operator new (std::size_t size, void* ptr) noexcept; But while it doesn't involve any actual allocation so bad allocation exceptions are e...
Cauda asked 2/11, 2014 at 12:32

2

Solved

C++'s new has an option to return a null pointer instead of throwing a bad_alloc exception when an allocation failed. Foo * pf = new(std::nothrow) Foo(1, 2, 3); (Yes, I understand this only prev...
Shriner asked 19/3, 2014 at 15:49

9

What is the ideal usage of std::nothrow?
Maddi asked 17/1, 2011 at 21:30

3

Solved

There is such code: #include <iostream> int main(){ for(;;){ int* ptr = new (std::nothrow) int; if(ptr == 0){ std::cout << 0 << std::endl; break; } } std::cin.get(); re...
Hemi asked 26/9, 2011 at 12:35
1

© 2022 - 2024 — McMap. All rights reserved.