How to guarantee clearing of nested std::array?

113 Views Asked by At

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)?

1

There are 1 best solutions below

0
user12002570 On BEST ANSWER

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 = {};