mardi 23 juin 2015

catch the exception from class member initialization "in-place"

I'm writing a code :

class aaa {
    std::regex re {"aaabbb"};
public:
    aaa() {}
...

you know std::regex can throw the exception. is there a technique in c++11/14 to catch this within a class?

similar to this:

class aaa {
    std::regex re;
public:
    aaa() 
    try 
       : re("aaabbb") {
    }
    catch(...) {
    }

Aucun commentaire:

Enregistrer un commentaire