Why isn't std::array::size static?

后端 未结 6 2037
执念已碎
执念已碎 2020-12-15 16:57

The size of std::array is known at compile time, but the size member function isn\'t static. Is there any reason for that? It\'s slightly inconvenient not to be

6条回答
  •  無奈伤痛
    2020-12-15 17:35

    Since C++11 you can use std::tuple_size on std::array to obtain the size as a compile time constant. See

    http://en.cppreference.com/w/cpp/container/array/tuple_size

提交回复
热议问题