C++11: defining function on std::array

前端 未结 2 841
栀梦
栀梦 2021-01-14 10:18

std::array takes two template parameters:

typename T // the element type
size_t N // the size of the array

I want to define a

2条回答
  •  抹茶落季
    2021-01-14 10:39

    The N needs to be a static value. You can, e.g., make a template argument:

    template 
    void f(std::array x) {
        ...
    }
    

    In your example, I would still pass the argument by reference, though:

    template 
    void f(std::array const& x) {
        ...
    }
    

提交回复
热议问题