Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 4
    Why not use a constructor? Commented Feb 13, 2022 at 0:15
  • It's a long story. I'm just asking if it's possible Commented Feb 13, 2022 at 0:17
  • 2
    It is possible by providing your own constructor. You'd need to explain why (you think) that is not good enough if you want a different answer Commented Feb 13, 2022 at 0:20
  • Can you please give me an example how is it possible by providing my own constructor Commented Feb 13, 2022 at 0:26
  • "Creative" alternative: struct S { std::array<int, 50> arr = []{ decltype(arr) rv; rv.fill(5); return rv; }(); }; Commented Feb 13, 2022 at 0:56