Timeline for Affect a repetition of an argument N times (for array construction)
Current License: CC BY-SA 4.0
15 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Sep 30 at 0:50 | vote | accept | einpoklum | ||
| Sep 29 at 1:47 | history | reopened |
Deduplicator einpoklum Peilonrayz♦ |
||
| Sep 28 at 16:51 | review | Reopen votes | |||
| Sep 29 at 1:56 | |||||
| Sep 28 at 16:24 | history | closed |
indi toolic Cris Luengo |
Not suitable for this site | |
| Sep 28 at 15:29 | history | became hot network question | |||
| Sep 28 at 15:17 | answer | added | Deduplicator | timeline score: 5 | |
| Sep 28 at 8:44 | answer | added | Toby Speight | timeline score: 4 | |
| Sep 27 at 18:33 | review | Close votes | |||
| Sep 28 at 16:25 | |||||
| Sep 27 at 15:00 | comment | added | einpoklum | @AjinkyaKamat: Yeah, I guess that does compile. I need to give that a longer look. Perhaps make it an answer? | |
| Sep 27 at 14:13 | comment | added | Ajinkya Kamat |
You are wrong. Not only does it compile but also T can be non default-constructible. Check this out godbolt.org/z/1YqPv6s87
|
|
| Sep 27 at 13:20 | history | edited | einpoklum | CC BY-SA 4.0 |
added 56 characters in body
|
| Sep 27 at 13:20 | comment | added | einpoklum |
@AjinkyaKamat: That doesn't even compile. Also, you seem to be assuming that T is default-constructible, which is not necessarily the case.
|
|
| Sep 27 at 10:37 | comment | added | Ajinkya Kamat |
This works since C++17. template<std::size_t N, typename T> auto array_repeat(T const& t) { return std::apply([&](auto... e) {return std::array{(e, t)...};}, std::array<int, N>{});}
|
|
| Sep 27 at 10:11 | history | edited | toolic | CC BY-SA 4.0 |
added 1 character in body; edited title
|
| Sep 27 at 9:19 | history | asked | einpoklum | CC BY-SA 4.0 |