相关疑难解决方法(0)

在std :: array上使用std :: extent

我有一个模板化的功能,我想static_assert它的类型有三个大小.此代码说明了我正在尝试做什么,但不起作用:

template < typename T >
void foo( T& param )
{
    // This line is the one that I need to figure out how to write
    static_assert( 3 == std::extent< T >::value, "param must have a size of 3" );
}

int main( void )
{
    int cArray[3];
    std::array< int, 3 > stdArray;

    foo( cArray );
    foo( stdArray );
}
Run Code Online (Sandbox Code Playgroud)

c++ arrays templates static-assert

5
推荐指数
2
解决办法
1582
查看次数

标签 统计

arrays ×1

c++ ×1

static-assert ×1

templates ×1