[ Web Proxy ]
URL:
Viewing: https://ru.cppreference.com/cpp/error/exception_ptr [Back]  [Original]

std::exception_ptr cppreference.com
cppreference.com

std::exception_ptr

cppreference.com
<tbody> </tbody>
typedef /* */ exception_ptr;
( C++11)

std::exception_ptr , , , , std::current_exception. std::exception_ptr , , , catch.

std::exception_ptr ; .

std::exception_ptr , null .

std::exception_ptr , . bool false, , true.

, std::exception_ptr, , std::exception_ptr, : std::exception_ptr (: ).

std::exception_ptr NullablePointer.

#include <exception>
#include <iostream>
#include <stdexcept>
#include <string>

void handle_eptr(std::exception_ptr eptr) //    
{
    try
    {
        if (eptr)
            std::rethrow_exception(eptr);
    }
    catch(const std::exception& e)
    {
        std::cout << " : '" << e.what() << "'\n";
    }
}

int main()
{
    std::exception_ptr eptr;

    try
    {
        std::string().at(1); //   std::out_of_range
    }
    catch(...)
    {
        eptr = std::current_exception(); // 
    }

    handle_eptr(eptr);

} //     std::out_of_range,
  //   eptr

:

 : 'basic_string::at: __n (which is 1) >= this->size() (which is 0)'

std::exception_ptr
( ) []
std::exception_ptr
() []
std::exception_ptr
() []

Web Proxy Viewer  |  New URL  |  Original Page