← Top stories Reading mode In C++, = default and {} are not the same constructor ↗ (opens external site) 131 points by surprisetalk 5 days ago | lemire.me | 199 comments on HN ↗ | Vote on HN ↗ (opens Hacker News) View full thread · View on Hacker News Comment thread (1) − quietbritishjim | 4 days ago | parent | reply on HN ↗ (opens Hacker News) | vote on HN ↗ (opens Hacker News) It's only rare because it's relatively recent. I expect it to become more widely used because it can be used for simulating named parameters: struct Params { int p1 = 1, p2 = 2, p3 = 3, p4 = 4, p5 = 5; }; void foo(Params p) {} int main() { foo({.p2 = 12, .p4 = 14}); } They have to be in the correct order though: // Not allowed foo({.p4 = 14, .p2 = 12});
Comment thread (1)