Boost logo

Boost Users :

Subject: [Boost-users] [type traits] redefine a type trait
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2014-07-21 19:24:14


Hello,

Question: is there a way to delete or remove a type trait once it has
been defined? And/or redefine it?

Consider, I've got a default type trait, something like this.

template<typename T>
struct throws_exceptions {
    static const bool value = true;
};

struct my_object {
//does some work with or without exception
};

template<>
struct throws_exceptions<my_object> {
    static const bool value = false;
}

However, in my unit test code, I want to override the default behavior
for test purposes.

template<>
struct throws_exceptions<my_object> {
    static const bool value = true;
}

Or just leave the type trait out.

Actually, I'm not sure I just considered an answer to my own question.

Possibly I need to separate the traits from the underlying things
being modified, and leave it as an option whether to include the
defaults, or define user-provided traits.

Best regards,

Michael Powell


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net