Re: Order of destructor execution.
 
__PPS__ wrote:
[..]
I think you made a mistake thinking that MutexLocker ( mut );  is the
same as MutexLocker mut;
It is, if 'MutexLocker' is a type.  I actually made a mistake of
thinking it would be a creation of a temporary object (that's all
*if* 'MutexLocker' is a type), but it isn't.  Here is the test you
can run
    class MutexLocker {
    public:
        MutexLocker() {} // default c-tor
        MutexLocker(int) {} // parameterized c-tor
        operator int() const { return 42; }
    };
    int mut = 0;
    int main() {
        MutexLocker(mut);
        return mut;
    }
What do you think this program's "main" will return to the system?
Please explain.
Another example, similar, of ill-formed code:
    class MutexLocker {
        MutexLocker() {} // default c-tor -- private!!!
    public:
        MutexLocker(int) {} // parameterized c-tor
    };
    int mut = 0;
    int main() {
        MutexLocker(mut); // should not compile
    }
Now, if 'MutexLocker' is NOT a type but instead, say, a macro that
expands into something like
    MutexLocker_t someUniqueVariableName123456(mut);
then further clarification may be required.
[..]
V
-- 
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask