Commit f3d6819
Add mandatory explicit discard, closes hsutter#305
Support `_ =` as a discard operation
- for example, `_ = vec.emplace_back(a,b,c);`
- emitted as `(void)`, not `std::ignore =` because the latter doesn't work with `void` returns and we want to support generic code where there might or might not be a return value in a given template instantiation
Make UFCS calls unconditionally add [[nodiscard]] always
- note: only added on compilers that support C++23's P2173
Take back `_ :=` as an anonymous deduced variable syntax - the name can be anonymous or the type can be anonymous, but not both
- yes, it would be easy to support making both anonymous (it did work before this commit, which had to explicitly add a check to disable it)
- rationale: if that were allowed to keep the returned object alive, that syntax would be dangerously close to '_ = f();' to discard the returned object, which is exactly opposite in a fundamentally important way (lifetime!) and such importantly opposite meanings deserve more than a one-character typo distance
- explicit discarding gets the nice syntax because it's likely more common
- but this shouldn't be any hardship because cases that use a type are still just as easy, e.g., `lock_guard`; before this commit `_ := lock_guard(mut);` worked, and after this commit that's disallowed but it's just as easy to write `_: lock_guard = mut;`
- to make this natural also for `finally`, I just got rid of the `finally` and `finally_success` helper functions, and gave those names to the types... it's a simpler design and I think an improvement in its own right, and `_: finally = code;` is slightly simpler to write (e.g., saves `(` `)` `;`, for example see `pure2-types-order-independence-and-nesting.cpp2`)
Remove return type from `contract_group::set_handler`
- not needed, since we already have `get_handler` if the current value is of interest
Add reflection `default_to_*` functions for `make_*` functions that ignore the returned bool
- arguably a clearer API, makes calling code intent more readable1 parent 99ed801 commit f3d6819
File tree
25 files changed
+234
-166
lines changed- include
- regression-tests
- test-results
- source
25 files changed
+234
-166
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | | - | |
329 | | - | |
| 328 | + | |
| 329 | + | |
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| |||
374 | 374 | | |
375 | 375 | | |
376 | 376 | | |
377 | | - | |
| 377 | + | |
378 | 378 | | |
379 | | - | |
380 | 379 | | |
381 | | - | |
382 | 380 | | |
383 | 381 | | |
384 | 382 | | |
| |||
685 | 683 | | |
686 | 684 | | |
687 | 685 | | |
| 686 | + | |
688 | 687 | | |
689 | 688 | | |
690 | 689 | | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
691 | 706 | | |
692 | 707 | | |
693 | 708 | | |
694 | 709 | | |
695 | 710 | | |
696 | 711 | | |
697 | | - | |
| 712 | + | |
698 | 713 | | |
699 | 714 | | |
700 | 715 | | |
| |||
703 | 718 | | |
704 | 719 | | |
705 | 720 | | |
706 | | - | |
| 721 | + | |
707 | 722 | | |
708 | 723 | | |
709 | 724 | | |
| |||
714 | 729 | | |
715 | 730 | | |
716 | 731 | | |
717 | | - | |
| 732 | + | |
718 | 733 | | |
719 | 734 | | |
720 | 735 | | |
| |||
723 | 738 | | |
724 | 739 | | |
725 | 740 | | |
726 | | - | |
| 741 | + | |
727 | 742 | | |
728 | 743 | | |
729 | 744 | | |
| |||
735 | 750 | | |
736 | 751 | | |
737 | 752 | | |
738 | | - | |
| 753 | + | |
739 | 754 | | |
740 | 755 | | |
741 | 756 | | |
| |||
744 | 759 | | |
745 | 760 | | |
746 | 761 | | |
747 | | - | |
| 762 | + | |
748 | 763 | | |
749 | 764 | | |
750 | 765 | | |
| |||
753 | 768 | | |
754 | 769 | | |
755 | 770 | | |
756 | | - | |
| 771 | + | |
757 | 772 | | |
758 | 773 | | |
759 | 774 | | |
| |||
762 | 777 | | |
763 | 778 | | |
764 | 779 | | |
765 | | - | |
| 780 | + | |
766 | 781 | | |
767 | 782 | | |
768 | 783 | | |
| |||
1347 | 1362 | | |
1348 | 1363 | | |
1349 | 1364 | | |
1350 | | - | |
| 1365 | + | |
1351 | 1366 | | |
1352 | 1367 | | |
1353 | | - | |
1354 | | - | |
| 1368 | + | |
| 1369 | + | |
1355 | 1370 | | |
1356 | | - | |
| 1371 | + | |
1357 | 1372 | | |
1358 | 1373 | | |
1359 | 1374 | | |
1360 | 1375 | | |
1361 | 1376 | | |
1362 | 1377 | | |
1363 | | - | |
| 1378 | + | |
1364 | 1379 | | |
1365 | 1380 | | |
1366 | 1381 | | |
1367 | | - | |
1368 | | - | |
1369 | | - | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
1370 | 1385 | | |
1371 | 1386 | | |
1372 | 1387 | | |
1373 | 1388 | | |
1374 | 1389 | | |
1375 | 1390 | | |
1376 | 1391 | | |
1377 | | - | |
1378 | | - | |
1379 | | - | |
1380 | | - | |
1381 | | - | |
1382 | 1392 | | |
1383 | 1393 | | |
1384 | 1394 | | |
1385 | 1395 | | |
1386 | 1396 | | |
1387 | 1397 | | |
1388 | | - | |
| 1398 | + | |
1389 | 1399 | | |
1390 | 1400 | | |
1391 | | - | |
1392 | | - | |
| 1401 | + | |
| 1402 | + | |
1393 | 1403 | | |
1394 | | - | |
| 1404 | + | |
1395 | 1405 | | |
1396 | | - | |
| 1406 | + | |
1397 | 1407 | | |
1398 | 1408 | | |
1399 | 1409 | | |
1400 | | - | |
1401 | | - | |
1402 | | - | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
1403 | 1413 | | |
1404 | 1414 | | |
1405 | 1415 | | |
1406 | 1416 | | |
1407 | 1417 | | |
1408 | 1418 | | |
1409 | | - | |
1410 | | - | |
1411 | | - | |
1412 | | - | |
1413 | | - | |
1414 | 1419 | | |
1415 | 1420 | | |
1416 | 1421 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
| 23 | + | |
24 | 24 | | |
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | | - | |
| 7 | + | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
37 | | - | |
| 37 | + | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| |||
Lines changed: 11 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
7 | 7 | | |
8 | | - | |
| 8 | + | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
20 | 22 | | |
21 | 23 | | |
| 24 | + | |
| 25 | + | |
22 | 26 | | |
23 | 27 | | |
24 | 28 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
52 | 52 | | |
53 | 53 | | |
0 commit comments