c++stdarray

How to guarantee clearing of nested std::array?


I have a nested std::array of std::tuple. For example,

std::array<std::array<std::pair<int*, float*>, 12>, 3> my_array;

How can I clear all elements so all the pointers are zeroed (i.e. nullptr)?


Solution

  • How can I clear all elements so all the pointers are zeroed (i.e. nullptrs)?

    Since you're using std::array, you could just just assign an empty std::array to my_array as shown below:

    my_array = {};