خرید بک لینک

Vote count: 0

Suppose I have this recurring block of code:

Class1 c1;
try {
    c1.parse(x);
} catch(Exception& e) {
    Class2 c2;
    try {
        c2.parse(x);
    } catch(Exception& e) {
        Class3 c3;
        try {
            // ...
        }
        // ...
    }
}

Obviously, what I am interested in, is the first Class# (#=1,2,3,...) instance for which parse does not throw an exception.

Optionally, Class1, ..., ClassN have a common superclass, and I can use that as a retu type.

What is a concise way to abstract this operation, considering it will recurr many times in the code?

Ok to use STL and Boost, not ok to use C++11, because of project requirements :( Macros are a gray zone.

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: سه شنبه 25 خرداد 1395 ساعت: 21:45

صفحه بندی