Skip to content

Commit

Permalink
don't use std::pair<> as it's not trivial_copyable
Browse files Browse the repository at this point in the history
  • Loading branch information
Dan Smith committed Jun 6, 2023
1 parent 33773ea commit 41e040e
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions six/modules/c++/six.sicd/unittests/test_AMP8I_PHS8I.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,15 +233,22 @@ static std::vector <std::complex<float>> read_8bit_ampphs(const std::string& tes
return retval;
}

static std::pair<uint64_t, uint64_t> to_AMP8I_PHS8I(const six::sicd::ImageData& imageData, const std::vector<std::complex<float>>& widebandData)
template <typename T>
struct Pair final // std::pair<T, U> is not trivial copyable
{
T first;
T second;
};

static Pair<uint64_t> to_AMP8I_PHS8I(const six::sicd::ImageData& imageData, const std::vector<std::complex<float>>& widebandData)
{
// image is far too big to call to_AMP8I_PHS8I() with DEBUG code
const auto size = sys::debug ? widebandData.size() / 200 : widebandData.size();
const std::span<const std::complex<float>> widebandData_(widebandData.data(), size);
std::vector<AMP8I_PHS8I_t> results(widebandData_.size());
imageData.to_AMP8I_PHS8I(widebandData_, std::span< AMP8I_PHS8I_t>(results.data(), results.size()), 0);

std::pair<uint64_t, uint64_t> retval(0, 0);
Pair<uint64_t> retval{ 0, 0 };
for (const auto& r : results)
{
retval.first += r.first;
Expand Down Expand Up @@ -272,7 +279,7 @@ TEST_CASE(read_8bit_ampphs_with_table)
imageData.amplitudeTable.reset(std::make_unique< six::AmplitudeTable>(AmpTable));
const auto actual = to_AMP8I_PHS8I(imageData, widebandData);
const auto expected(sys::debug ?
std::pair<uint64_t, uint64_t>(12647523, 16973148) : std::pair<uint64_t, uint64_t>(3044868397, 3394353166));
Pair<uint64_t>{12647523, 16973148} : Pair<uint64_t>{ 3044868397, 3394353166 });
//TEST_ASSERT_EQ(actual.first, expected.first); // TODO
TEST_ASSERT_EQ(actual.second, expected.second);
}
Expand All @@ -291,7 +298,7 @@ TEST_CASE(read_8bit_ampphs_no_table)
six::sicd::ImageData imageData;
const auto actual = to_AMP8I_PHS8I(imageData, widebandData);
const auto expected(sys::debug ?
std::pair<uint64_t, uint64_t>(12647654, 16973148) : std::pair<uint64_t, uint64_t>(3044873160, 3394353122));
Pair<uint64_t>{12647654, 16973148} : Pair<uint64_t>{ 3044873160, 3394353122 });
TEST_ASSERT_EQ(actual.first, expected.first);
TEST_ASSERT_EQ(actual.second, expected.second);
}
Expand Down

0 comments on commit 41e040e

Please sign in to comment.