I want to make sure that one of the template parameters of my class is derived of a specific (abstract) class. With this intention is 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 be derived of MDDB_Service::MDDB_Web::abstract_record");
...
But I get a compiler error:
error C2226: syntax error : unexpected type 'std::is_base_of<abstract_record,Record>'
Is this a problem of MSVC (I'm using Visual Studio 2013 Express) or did I got something wrong, e.g. how do I solve this?
The result of the is_base_of
verification is accessible via a static nested value
data member:
static_assert(std::is_base_of<abstract_record, Record>::value
// ~~~~~~^
, "Record must be derived of MDDB_Service::MDDB_Web::abstract_record");
If your compiler supports constexpr evaluation of a conversion operator, you can instead use the below syntax:
static_assert(std::is_base_of<abstract_record, Record>{}
// ↑↑
, "Record must be derived of MDDB_Service::MDDB_Web::abstract_record");