Talk:cpp/error/make exception ptr
From cppreference.com
The example looks incorrect as no argument is given to std::current_exception()
[edit] Misleading?
The article says: "The parameter is passed by value and is subject to slicing."
That's true, but I think misleading, because it makes it sound as if slicing happens normally.
In fact, if you call std::make_exception without specifying the type to specialize on, then it will not slice.
auto ex = std::make_exception_ptr(std::runtime_error("No slicing here"));
That's because this is equivalent to:
auto ex = std::make_exception_ptr<std::runtime_error>(std::runtime_error("No slicing here"));
It will only slice if you do something like this:
auto ex = std::make_exception_ptr<std::exception>(std::runtime_error("I am a runtime error!"));
68.197.116.79 20:03, 23 February 2020 (PST)