Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement P1951R1: Default Template Arguments For pair's Forwarding Constructor #2009

Merged
merged 10 commits into from
Jul 30, 2021
Merged
6 changes: 3 additions & 3 deletions stl/inc/utility
Original file line number Diff line number Diff line change
Expand Up @@ -185,22 +185,22 @@ struct pair { // store a pair of values
#endif // ^^^ !_HAS_CONDITIONAL_EXPLICIT ^^^

#if _HAS_CONDITIONAL_EXPLICIT
template <class _Other1, class _Other2,
template <class _Other1 = _Ty1, class _Other2 = _Ty2,
enable_if_t<conjunction_v<is_constructible<_Ty1, _Other1>, is_constructible<_Ty2, _Other2>>, int> = 0>
constexpr explicit(!conjunction_v<is_convertible<_Other1, _Ty1>, is_convertible<_Other2, _Ty2>>)
pair(_Other1&& _Val1, _Other2&& _Val2) noexcept(
is_nothrow_constructible_v<_Ty1, _Other1>&& is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
: first(_STD forward<_Other1>(_Val1)), second(_STD forward<_Other2>(_Val2)) {}
#else // ^^^ _HAS_CONDITIONAL_EXPLICIT ^^^ / vvv !_HAS_CONDITIONAL_EXPLICIT vvv
template <class _Other1, class _Other2,
template <class _Other1 = _Ty1, class _Other2 = _Ty2,
enable_if_t<conjunction_v<is_constructible<_Ty1, _Other1>, is_constructible<_Ty2, _Other2>,
is_convertible<_Other1, _Ty1>, is_convertible<_Other2, _Ty2>>,
int> = 0>
constexpr pair(_Other1&& _Val1, _Other2&& _Val2) noexcept(
is_nothrow_constructible_v<_Ty1, _Other1>&& is_nothrow_constructible_v<_Ty2, _Other2>) // strengthened
: first(_STD forward<_Other1>(_Val1)), second(_STD forward<_Other2>(_Val2)) {}

template <class _Other1, class _Other2,
template <class _Other1 = _Ty1, class _Other2 = _Ty2,
enable_if_t<conjunction_v<is_constructible<_Ty1, _Other1>, is_constructible<_Ty2, _Other2>,
negation<conjunction<is_convertible<_Other1, _Ty1>, is_convertible<_Other2, _Ty2>>>>,
int> = 0>
Expand Down
1 change: 1 addition & 0 deletions stl/inc/yvals_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
// P1164R1 Making create_directory() Intuitive
// P1165R1 Consistently Propagating Stateful Allocators In basic_string's operator+()
// P1902R1 Missing Feature-Test Macros 2017-2019
// P1951R1 Default Template Arguments For pair's Forwarding Constructor
StephanTLavavej marked this conversation as resolved.
Show resolved Hide resolved

// _HAS_CXX17 directly controls:
// P0005R4 not_fn()
Expand Down
1 change: 1 addition & 0 deletions tests/std/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -420,6 +420,7 @@ tests\P1502R1_standard_library_header_units
tests\P1614R2_spaceship
tests\P1645R1_constexpr_numeric
tests\P1682R3_to_underlying
tests\P1951R1_default_arguments_pair_forward_ctor
tests\P2162R2_std_visit_for_derived_classes_from_variant
tests\VSO_0000000_allocator_propagation
tests\VSO_0000000_any_calling_conventions
Expand Down
54 changes: 27 additions & 27 deletions tests/std/tests/P0067R5_charconv/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,39 +212,39 @@ constexpr const char* output_max_digit[] = {"skip0", "skip1", "11", "12", "13",
// https://www.wolframalpha.com : Table[BaseForm[k, n], {k, {MEOW, MEOW, MEOW}}, {n, 2, 36}]
constexpr uint64_t stress_chunks_positive = 12000000345000678900ULL;
constexpr pair<uint64_t, array<const char*, 37>> output_positive[] = {
{123, {{"skip0", "skip1", "1111011", "11120", "1323", "443", "323", "234", "173", "146", "123", "102", "a3", "96",
"8b", "83", "7b", "74", "6f", "69", "63", "5i", "5d", "58", "53", "4n", "4j", "4f", "4b", "47", "43",
"3u", "3r", "3o", "3l", "3i", "3f"}}},
{INT8_MAX, {{"skip0", "skip1", "1111111", "11201", "1333", "1002", "331", "241", "177", "151", "127", "106", "a7",
"9a", "91", "87", "7f", "78", "71", "6d", "67", "61", "5h", "5c", "57", "52", "4n", "4j", "4f", "4b",
"47", "43", "3v", "3s", "3p", "3m", "3j"}}},
{161, {{"skip0", "skip1", "10100001", "12222", "2201", "1121", "425", "320", "241", "188", "161", "137", "115",
"c5", "b7", "ab", "a1", "98", "8h", "89", "81", "7e", "77", "70", "6h", "6b", "65", "5q", "5l", "5g",
"5b", "56", "51", "4t", "4p", "4l", "4h"}}},
{123U, {{"skip0", "skip1", "1111011", "11120", "1323", "443", "323", "234", "173", "146", "123", "102", "a3", "96",
CaseyCarter marked this conversation as resolved.
Show resolved Hide resolved
"8b", "83", "7b", "74", "6f", "69", "63", "5i", "5d", "58", "53", "4n", "4j", "4f", "4b", "47", "43",
"3u", "3r", "3o", "3l", "3i", "3f"}}},
{uint64_t{INT8_MAX}, {{"skip0", "skip1", "1111111", "11201", "1333", "1002", "331", "241", "177", "151", "127",
"106", "a7", "9a", "91", "87", "7f", "78", "71", "6d", "67", "61", "5h", "5c", "57", "52",
"4n", "4j", "4f", "4b", "47", "43", "3v", "3s", "3p", "3m", "3j"}}},
{161U, {{"skip0", "skip1", "10100001", "12222", "2201", "1121", "425", "320", "241", "188", "161", "137", "115",
"c5", "b7", "ab", "a1", "98", "8h", "89", "81", "7e", "77", "70", "6h", "6b", "65", "5q", "5l", "5g",
"5b", "56", "51", "4t", "4p", "4l", "4h"}}},
{UINT8_MAX, {{"skip0", "skip1", "11111111", "100110", "3333", "2010", "1103", "513", "377", "313", "255", "212",
"193", "168", "143", "120", "ff", "f0", "e3", "d8", "cf", "c3", "bd", "b2", "af", "a5", "9l", "9c",
"93", "8n", "8f", "87", "7v", "7o", "7h", "7a", "73"}}},
{1729, {{"skip0", "skip1", "11011000001", "2101001", "123001", "23404", "12001", "5020", "3301", "2331", "1729",
"1332", "1001", "a30", "8b7", "7a4", "6c1", "5gc", "561", "4f0", "469", "3j7", "3cd", "364", "301",
"2j4", "2ed", "2a1", "25l", "21i", "1rj", "1oo", "1m1", "1jd", "1gt", "1ee", "1c1"}}},
{INT16_MAX, {{"skip0", "skip1", "111111111111111", "1122221121", "13333333", "2022032", "411411", "164350", "77777",
"48847", "32767", "22689", "16b67", "11bb7", "bd27", "9a97", "7fff", "6b68", "5b27", "4eeb", "41i7",
"3b67", "31f9", "2flf", "28l7", "22ah", "1mc7", "1hpg", "1dm7", "19rq", "16c7", "1330", "vvv",
"u2v", "sbp", "qq7", "pa7"}}},
{57494, {{"skip0", "skip1", "1110000010010110", "2220212102", "32002112", "3314434", "1122102", "326423", "160226",
"86772", "57494", "3a218", "29332", "20228", "16d4a", "1207e", "e096", "bbg0", "9f82", "8750", "73ee",
"647h", "58h8", "4gfh", "43je", "3goj", "3718", "2onb", "2h9a", "2aag", "23qe", "1spk", "1o4m", "1jq8",
"1fp0", "1bwo", "18d2"}}},
{1729U, {{"skip0", "skip1", "11011000001", "2101001", "123001", "23404", "12001", "5020", "3301", "2331", "1729",
"1332", "1001", "a30", "8b7", "7a4", "6c1", "5gc", "561", "4f0", "469", "3j7", "3cd", "364", "301",
"2j4", "2ed", "2a1", "25l", "21i", "1rj", "1oo", "1m1", "1jd", "1gt", "1ee", "1c1"}}},
{uint64_t{INT16_MAX}, {{"skip0", "skip1", "111111111111111", "1122221121", "13333333", "2022032", "411411",
"164350", "77777", "48847", "32767", "22689", "16b67", "11bb7", "bd27", "9a97", "7fff",
"6b68", "5b27", "4eeb", "41i7", "3b67", "31f9", "2flf", "28l7", "22ah", "1mc7", "1hpg",
"1dm7", "19rq", "16c7", "1330", "vvv", "u2v", "sbp", "qq7", "pa7"}}},
{57494U, {{"skip0", "skip1", "1110000010010110", "2220212102", "32002112", "3314434", "1122102", "326423", "160226",
"86772", "57494", "3a218", "29332", "20228", "16d4a", "1207e", "e096", "bbg0", "9f82", "8750", "73ee",
"647h", "58h8", "4gfh", "43je", "3goj", "3718", "2onb", "2h9a", "2aag", "23qe", "1spk", "1o4m", "1jq8",
"1fp0", "1bwo", "18d2"}}},
{UINT16_MAX, {{"skip0", "skip1", "1111111111111111", "10022220020", "33333333", "4044120", "1223223", "362031",
"177777", "108806", "65535", "45268", "31b13", "23aa2", "19c51", "14640", "ffff", "d5d0", "b44f",
"9aa4", "83gf", "71cf", "638j", "58k8", "4hif", "44la", "3iof", "38o6", "2rgf", "2jqo", "2cof",
"2661", "1vvv", "1r5u", "1mnh", "1ihf", "1ekf"}}},
{71125478, {{"skip0", "skip1", "100001111010100100111100110", "11221211112210222", "10033110213212", "121202003403",
"11020244342", "1522361624", "417244746", "157745728", "71125478", "3716a696", "1b9a06b2",
"11973ba8", "9636514", "639e338", "43d49e6", "2g19gfb", "21b9d18", "19dec94", "124addi", "h8f25b",
"dhdfa6", "b13hg2", "8m91he", "7720j3", "5pgj58", "4pmelq", "43k17i", "3dg8ek", "2ro898", "2f0et8",
"23qif6", "1qw5lh", "1j7l7s", "1cdvli", "16cgrq"}}},
{INT32_MAX,
{71125478U, {{"skip0", "skip1", "100001111010100100111100110", "11221211112210222", "10033110213212",
"121202003403", "11020244342", "1522361624", "417244746", "157745728", "71125478", "3716a696",
"1b9a06b2", "11973ba8", "9636514", "639e338", "43d49e6", "2g19gfb", "21b9d18", "19dec94", "124addi",
"h8f25b", "dhdfa6", "b13hg2", "8m91he", "7720j3", "5pgj58", "4pmelq", "43k17i", "3dg8ek", "2ro898",
"2f0et8", "23qif6", "1qw5lh", "1j7l7s", "1cdvli", "16cgrq"}}},
{uint64_t{INT32_MAX},
{{"skip0", "skip1", "1111111111111111111111111111111", "12112122212110202101", "1333333333333333",
"13344223434042", "553032005531", "104134211161", "17777777777", "5478773671", "2147483647", "a02220281",
"4bb2308a7", "282ba4aaa", "1652ca931", "c87e66b7", "7fffffff", "53g7f548", "3928g3h1", "27c57h32",
Expand All @@ -270,7 +270,7 @@ constexpr pair<uint64_t, array<const char*, 37>> output_positive[] = {
"4d0d5e232c53", "2d63h403i580", "1bf5h8185hdj", "kc3g550fkcg", "d41id5k9984", "8ef5n0him4g", "5i2dijfe1la",
"3me22fm5fhi", "2hfmhgg73kd", "1ngpfabr53c", "18i7220bh11", "rm0lcjngpa", "kk1elesni1", "fgfge3c3fg",
"bp4q5l6bjg", "8xna46jp0k", "6wejomvji5", "5di2s1qhv4"}}},
{INT64_MAX,
{uint64_t{INT64_MAX},
{{"skip0", "skip1", "111111111111111111111111111111111111111111111111111111111111111",
"2021110011022210012102010021220101220221", "13333333333333333333333333333333",
"1104332401304422434310311212", "1540241003031030222122211", "22341010611245052052300",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

RUNALL_INCLUDE ..\usual_matrix.lst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) Microsoft Corporation.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

#include <memory>
#include <utility>

using namespace std;

void test() {
pair<int, unique_ptr<int>> p1{42, {}};
pair<unique_ptr<int>, int> p2{{}, 42};
pair<unique_ptr<int>, unique_ptr<int>> p3{{}, {}};
(void) p1;
(void) p2;
(void) p3;
}

int main() {} // COMPILE-ONLY