f



std::any and std::exception_ptr

{ edited by mod to shorten lines to ~70 characters. -mod }

[mistakenly posted to comp.lang.c++ before]

N3804 proposes the introduction of std::any. 

Now, C++ already has an "any"-like type, namely std::exception_ptr.
Semantically, after the introduction of std::any, exception_ptr will be
a special case of std::any, namely a semantical std::any initialized by
a caught exception. 

Wouldn't it make sense to make these two interoperate nicely? In
particular, 

** std::exception_ptr should be able to be converted into a std::any,
as,
currently, the only way of looking into an exception_ptr is re-throwing
and catching immediately (please correct me if I am wrong). 

** std::rethrow_exception should accept a std::any, throwing its
contents
(not the std::any itself). This would permit the preparation of
a potential exception in advance and throwing it at a later point in
time. 

Best regards, 
Johannes 


-- 
      [ See http://www.gotw.ca/resources/clcm.htm for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]

0
johannes
12/22/2015 6:40:44 AM
comp.lang.c++.moderated 10738 articles. 1 followers. allnor (8509) is leader. Post Follow

0 Replies
899 Views

Similar Articles

[PageSpeed] 31

Reply:

Similar Artilces:

which headers to #include
Suppose I have a program which uses 'ostream' type as the parameter type for a function and 'cout' object for writing into the standard output. Following is my understanding regarding, which headers to #include for this scenario. Since the program uses 'cout' object, I have to #include <iostream> header for 'cout'. In the ISO/IEC-14882:2003 document, in page 608, in section 27.3 - Standard iostream objects, the synopsis for the header <iostream> mentions the following line(apart from other statements): extern ostream cout; From the ab...

Preconditions and semantics of std::is_constructible and std::is_assignable in N3242 (C++0x draft)
1) Preconditions for std::is_constructible<T, Args...> are specified as follows: T and all types in the parameter pack Args shall be complete types, (possibly cv-qualified) void, or arrays of unknown bound. If my understanding is correct, X const & is complete type regardless of whether X is complete type, so the following program is well- defined and shall print zero: ------------------------------------------------- #include <iostream> #include <type_traits> struct X; int main() { std::cout << (int)std::is_constructible<X cons...

Thanks,Got the std free(Re: I want C++ std free[sorry OT]
I don't know who sent it free. But I got the .pdf free.I am very thanks full to the one who sent it for me. If any one wants the .pdf free kindly mail me. Thanks again for the unknown sender. -- "combination is the heart of chess" A.Alekhine Mail to: sathyashrayan AT gmail DOT com "sathyashrayan" <look_at_the_bottom@nomail.com> skrev i en meddelelse news:37qgmlF5hip5bU1@individual.net... > I don't know who sent it free. But I got the .pdf free.I am very thanks > full to the one who sent it for me. If any one wan...

Solaris Studio C++ std::cout std::string core dump under multithread environment.
Hi, Recently I meet a very strange core dump issue and I investigate this issue for long time and I have some ideas, however I have no idea it is correct or not. So I want some guys could give me some suggestions or tips, thanks a lot. The environment: Solaris X86 64bit, Solaris Studio C++ 12 (Sun Studio C++) with -mt -pthread and libCstd.so, and use libumem library. The core dump point is as follows: // ci is a int, cn and sv is a string // and I am sure ci, cn and sv is only function local variables and they // aren't shared by multithreads cout<<" ...

Thread-safety of assignment of std::exception_ptr (C++0x)
Suppose I run a couple of functions in parallel, catching an exception if either throws. If both throw, I want to catch one of the exceptions, but I don't care which one. I might try this: std::exception_ptr xp; std::async([&]{ try { doThis(); } catch(...) { xp = std::current_exception(); } }); std::async([&]{ try { doThat(); } catch(...) { xp = std::current_exception(); } }); if (xp) { // at least one of the tasks above threw } This can work only if assignment to xp (i.e., a std::exception_ptr object) is thread-safe. I see no su...

How to read an input text from keyboard by the std. lang. C?
Hello, how to read an input text from keyboard (on a console) by the standard languace C, please? I really need a tip about this question. TIA, Vinicius. What kind of input? Do you want to read a word? A sentence? A number? There's more than one way to get input from stdin, but for the most part you'll find yourself using fgets: #include <stdio.h> #include <stdlib.h> int main(void) { char buffer[BUFSIZ]; printf("Enter some text: "); fflush(stdout); if (fgets(buffer, sizeof buffer, stdin) == NULL) { fprintf(stderr, "Input error\n"); return EXIT_FAIL...

std::copy_backwards vs std::reverse_copy vs std::copy with reverse iterators
It seems all three can be used to accomplish almost identical tasks. Can someone chime in with their thoughts on their relative merits? As a concrete example, recently I was using reverse iterators to push_back on a vector in reverse order. std::vector<Elem> srcVec; std::vector<Elem> dstVec; std::copy(srcVec.rbegin(), srcVec.rend(), std::back_inserter(dstVec)); It occured to me that std::copy_backwards, and std::reverse_copy could be used to accomplish the same task, but I wasn't clear on why both alternatives are available. -- ...

Q: Convert std::string to std::wstring using std::ctype widen()
Hi All, I've done a little homework (I've read responses to similar from P.J. Plauger and Dietmar Kuehl), and wanted to verify with the Group. Below is what I am performing (Stroustrup's Appendix D recommendation won't compile in Microsoft VC++ 6.0). My question is in reference to MultiByte Character Sets. Will this code perform as expected? I understand every problem has a simple and elegant solution that is wrong. I generally use US English or Unicode, so I don't encounter a lot of issues others may see (a multibyte character using std::string). I have verified it work...

std::transform for std::map
Hi, it doesn't seem to be possible to use transform for maps. #include <algorithm> #include <map> #include <iterator> #include <vector> #include <iostream> using namespace std; int doit(int w) { return w+1; } int main() { map<int,int> m; vector<int> v; m[0]=42; v.push_back(42); //transform(m.begin(),m.end(),m.begin(),doit); (*) transform(v.begin(),v.end(),v.begin(),doit); copy(v.begin(),v.end(),ostream_iterator<int>(cout," ")); cout<<endl; } I understand syntactically why the line (*) ...

std::terminate() and std::unexpected()
Another post that would be better placed at csc ... I'm looking for clarification on an issue in the standard. In 18.7.2.4 (std::unexpected()) and 18.7.3.3 (std::terminate()), the standards says: "2 Effects: Calls the unexpected_handler/terminate_handler function in effect immediately after evaluating the throw-expression, if called by the implementation, or calls the current unexpected_handler/ terminate_handler, if called by the program." Consider this snippet: ------------------------ void fn1() { std::cerr << "fn1\n"; std::terminate(); } void fn2() { std::c...

std output and std error
Hi , I have a line in script as below. METHODRES="$(ls -1 ${L_ROLLBACK_DIR}/${L_ROLLBACK_FILE}* 2>&1)" i think if file is present in above case the value of METHODRES will be 0. wat is the significance of (2>&1) i do not understand much. I think it will output std err to std output by this (2>&1) . I am not sure what will the value of METHODRES in error cases. Will any one clear my doubts . Thanks in Advance !!! Regards Aki On 2009-05-07, aki <akhileshrawat007@gmail.com> wrote: > > > Hi , > > I have a line in script as below. >...

std::fstream and std::string
I think the stl is great and I enjoy using it, but there are times when it feels non-elegant, or inconsistent to me. For example, why was fstream.open not written to work directly with a std::string parameter? -Luther --- [ comp.std.c++ is moderated. To submit articles, try just posting with ] [ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ] [ --- Please see the FAQ before posting. --- ] [ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html ] Luther Baker wrote: > I think the stl is great and I en...

from std::string to std::istream?
Can I convert a std::string to a std::istream object? -- -Gernot int main(int argc, char** argv) {printf ("%silto%c%cf%cgl%ssic%ccom%c", "ma", 58, 'g', 64, "ba", 46, 10);} On 2005-03-17, Gernot Frisch <Me@Privacy.net> wrote: > Can I convert a std::string to a std::istream object? The question doesn't even make sense. What are you trying to do ? Cheers, -- Donovan Rebbechi http://pegasus.rutgers.edu/~elflord/ "Gernot Frisch" <Me@Privacy.net> wrote... > Can I convert a std::string to a std::istream object? No. But...

Web resources about - std::any and std::exception_ptr - comp.lang.c++.moderated

Resources last updated: 1/24/2016 8:30:38 PM