Is there std::memset equivalent for std::array?

  • A+
Category:Languages

Is there a memset equivalent for std::array? I think memset is supposed to perform better when initializing an array to zero than looping over the array. I searched one for std::array but could not find anything online.

 


Use the array's fill() method, that is what its purpose is.

If you fill it with 0 (for integers, for instance), then the compiler may optimize it if it can (often does, you can look at the generated code).

Comment

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: