Instead of storing double in double and then truncating to int, store int in long
and then widen to long long. This preserves test coverage (as these tests are
interested in various tuple conversions) while avoiding truncation warnings.
test/std/utilities/tuple/tuple.tuple/tuple.cnstr/const_pair.pass.cpp
Since we aren't physically truncating anymore, t1 is equal to p0.
test/std/utilities/tuple/tuple.tuple/tuple.cnstr/convert_copy.pass.cpp
One edit is different from the usual pattern. Previously, we were storing
double in double and then converting to A, which has an implicitly converting
constructor from int. Now, we're storing int in int and then converting to A,
avoiding the truncation.
Fixes D27542.
llvm-svn: 289109
int main()
{
{
- typedef std::pair<double, char> T0;
- typedef std::tuple<int, short> T1;
- T0 t0(2.5, 'a');
+ typedef std::pair<long, char> T0;
+ typedef std::tuple<long long, short> T1;
+ T0 t0(2, 'a');
T1 t1;
t1 = t0;
assert(std::get<0>(t1) == 2);
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1;
t1 = t0;
assert(std::get<0>(t1) == 2);
}
{
- typedef std::tuple<double, char> T0;
- typedef std::tuple<int, int> T1;
- T0 t0(2.5, 'a');
+ typedef std::tuple<long, char> T0;
+ typedef std::tuple<long long, int> T1;
+ T0 t0(2, 'a');
T1 t1;
t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
- typedef std::tuple<double, char, D> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', D(3));
+ typedef std::tuple<long, char, D> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', D(3));
T1 t1;
t1 = t0;
assert(std::get<0>(t1) == 2);
{
D d(3);
D d2(2);
- typedef std::tuple<double, char, D&> T0;
- typedef std::tuple<int, int, B&> T1;
- T0 t0(2.5, 'a', d2);
- T1 t1(1.5, 'b', d);
+ typedef std::tuple<long, char, D&> T0;
+ typedef std::tuple<long long, int, B&> T1;
+ T0 t0(2, 'a', d2);
+ T1 t1(1, 'b', d);
t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
}
{
- typedef std::tuple<double, char> T0;
- typedef std::tuple<int, int> T1;
- T0 t0(2.5, 'a');
+ typedef std::tuple<long, char> T0;
+ typedef std::tuple<long long, int> T1;
+ T0 t0(2, 'a');
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
- typedef std::tuple<double, char, D> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', D(3));
+ typedef std::tuple<long, char, D> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', D(3));
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
{
D d(3);
D d2(2);
- typedef std::tuple<double, char, D&> T0;
- typedef std::tuple<int, int, B&> T1;
- T0 t0(2.5, 'a', d2);
- T1 t1(1.5, 'b', d);
+ typedef std::tuple<long, char, D&> T0;
+ typedef std::tuple<long long, int, B&> T1;
+ T0 t0(2, 'a', d2);
+ T1 t1(1, 'b', d);
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
assert(std::get<2>(t1).id_ == 2);
}
{
- typedef std::tuple<double, char, std::unique_ptr<D>> T0;
- typedef std::tuple<int, int, std::unique_ptr<B>> T1;
- T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+ typedef std::tuple<long, char, std::unique_ptr<D>> T0;
+ typedef std::tuple<long long, int, std::unique_ptr<B>> T1;
+ T0 t0(2, 'a', std::unique_ptr<D>(new D(3)));
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
int main()
{
{
- typedef std::pair<double, std::unique_ptr<D>> T0;
- typedef std::tuple<int, std::unique_ptr<B>> T1;
- T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+ typedef std::pair<long, std::unique_ptr<D>> T0;
+ typedef std::tuple<long long, std::unique_ptr<B>> T1;
+ T0 t0(2, std::unique_ptr<D>(new D(3)));
T1 t1;
t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
int main()
{
{
- typedef std::pair<double, int> T0;
- typedef std::tuple<int, double> T1;
+ typedef std::pair<long, int> T0;
+ typedef std::tuple<long long, double> T1;
T0 t0(2, 3);
T1 t1(std::allocator_arg, A1<int>(5), t0);
assert(std::get<0>(t1) == 2);
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1(std::allocator_arg, A1<int>(), t0);
assert(std::get<0>(t1) == 2);
}
assert(std::get<1>(t1) == 3);
}
{
- typedef std::tuple<double, int, int> T0;
- typedef std::tuple<int, alloc_first, alloc_last> T1;
- T0 t0(1.5, 2, 3);
+ typedef std::tuple<long, int, int> T0;
+ typedef std::tuple<long long, alloc_first, alloc_last> T1;
+ T0 t0(1, 2, 3);
alloc_first::allocator_constructed = false;
alloc_last::allocator_constructed = false;
T1 t1(std::allocator_arg, A1<int>(5), t0);
int main()
{
{
- typedef std::pair<double, char> T0;
- typedef std::tuple<int, short> T1;
- T0 t0(2.5, 'a');
+ typedef std::pair<long, char> T0;
+ typedef std::tuple<long long, short> T1;
+ T0 t0(2, 'a');
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == short('a'));
}
#if TEST_STD_VER > 11
{
- typedef std::pair<double, char> P0;
- typedef std::tuple<int, short> T1;
- constexpr P0 p0(2.5, 'a');
+ typedef std::pair<long, char> P0;
+ typedef std::tuple<long long, short> T1;
+ constexpr P0 p0(2, 'a');
constexpr T1 t1 = p0;
- static_assert(std::get<0>(t1) != std::get<0>(p0), "");
+ static_assert(std::get<0>(t1) == std::get<0>(p0), "");
static_assert(std::get<1>(t1) == std::get<1>(p0), "");
static_assert(std::get<0>(t1) == 2, "");
static_assert(std::get<1>(t1) == short('a'), "");
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
}
#if TEST_STD_VER > 11
{
- typedef std::tuple<double> T0;
+ typedef std::tuple<int> T0;
typedef std::tuple<A> T1;
- constexpr T0 t0(2.5);
+ constexpr T0 t0(2);
constexpr T1 t1 = t0;
static_assert(std::get<0>(t1) == 2, "");
}
}
#endif
{
- typedef std::tuple<double, char> T0;
- typedef std::tuple<int, int> T1;
- T0 t0(2.5, 'a');
+ typedef std::tuple<long, char> T0;
+ typedef std::tuple<long long, int> T1;
+ T0 t0(2, 'a');
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
- typedef std::tuple<double, char, D> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', D(3));
+ typedef std::tuple<long, char, D> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', D(3));
T1 t1 = t0;
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
D d(3);
- typedef std::tuple<double, char, D&> T0;
- typedef std::tuple<int, int, B&> T1;
- T0 t0(2.5, 'a', d);
+ typedef std::tuple<long, char, D&> T0;
+ typedef std::tuple<long long, int, B&> T1;
+ T0 t0(2, 'a', d);
T1 t1 = t0;
d.id_ = 2;
assert(std::get<0>(t1) == 2);
assert(std::get<2>(t1).id_ == 2);
}
{
- typedef std::tuple<double, char, int> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', 3);
+ typedef std::tuple<long, char, int> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', 3);
T1 t1(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
int main()
{
{
- typedef std::tuple<double> T0;
- typedef std::tuple<int> T1;
- T0 t0(2.5);
+ typedef std::tuple<long> T0;
+ typedef std::tuple<long long> T1;
+ T0 t0(2);
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
}
{
- typedef std::tuple<double, char> T0;
- typedef std::tuple<int, int> T1;
- T0 t0(2.5, 'a');
+ typedef std::tuple<long, char> T0;
+ typedef std::tuple<long long, int> T1;
+ T0 t0(2, 'a');
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
- typedef std::tuple<double, char, D> T0;
- typedef std::tuple<int, int, B> T1;
- T0 t0(2.5, 'a', D(3));
+ typedef std::tuple<long, char, D> T0;
+ typedef std::tuple<long long, int, B> T1;
+ T0 t0(2, 'a', D(3));
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
}
{
D d(3);
- typedef std::tuple<double, char, D&> T0;
- typedef std::tuple<int, int, B&> T1;
- T0 t0(2.5, 'a', d);
+ typedef std::tuple<long, char, D&> T0;
+ typedef std::tuple<long long, int, B&> T1;
+ T0 t0(2, 'a', d);
T1 t1 = std::move(t0);
d.id_ = 2;
assert(std::get<0>(t1) == 2);
assert(std::get<2>(t1).id_ == 2);
}
{
- typedef std::tuple<double, char, std::unique_ptr<D>> T0;
- typedef std::tuple<int, int, std::unique_ptr<B>> T1;
- T0 t0(2.5, 'a', std::unique_ptr<D>(new D(3)));
+ typedef std::tuple<long, char, std::unique_ptr<D>> T0;
+ typedef std::tuple<long long, int, std::unique_ptr<B>> T1;
+ T0 t0(2, 'a', std::unique_ptr<D>(new D(3)));
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1) == int('a'));
int main()
{
{
- typedef std::pair<double, std::unique_ptr<D>> T0;
- typedef std::tuple<int, std::unique_ptr<B>> T1;
- T0 t0(2.5, std::unique_ptr<D>(new D(3)));
+ typedef std::pair<long, std::unique_ptr<D>> T0;
+ typedef std::tuple<long long, std::unique_ptr<B>> T1;
+ T0 t0(2, std::unique_ptr<D>(new D(3)));
T1 t1 = std::move(t0);
assert(std::get<0>(t1) == 2);
assert(std::get<1>(t1)->id_ == 3);