c++ - Static assertion of `is_base_of` in templated class fails with unexpected type in MSVC -


i want make sure 1 of template parameters of class derived of specific (abstract) class. intention wrote this

class abstract_record     {};         template<typename record, typename container = std::vector>  //requires sequencecontainer<container> //see iso/iec prf ts 19217     class mddb_adapter : public wt::wabstracttablemodel     {         static_assert(std::is_base_of<abstract_record, record>,"record must derived of mddb_service::mddb_web::abstract_record"); ... 

but compiler error:

error c2226: syntax error : unexpected type 'std::is_base_of<abstract_record,record>'

is problem of msvc (i'm using visual studio 2013 express) or did got wrong, e.g. how solve this?

the result of is_base_of verification accessible via static nested value data member:

static_assert(std::is_base_of<abstract_record, record>::value //                                                    ~~~~~~^      , "record must derived of mddb_service::mddb_web::abstract_record"); 

if compiler supports constexpr evaluation of conversion operator, can instead use below syntax:

static_assert(std::is_base_of<abstract_record, record>{} //                                                    ↑↑      , "record must derived of mddb_service::mddb_web::abstract_record"); 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -