Skip to content

Commit

Permalink
Workaround for bug in MSVC 19.35
Browse files Browse the repository at this point in the history
  • Loading branch information
lelegard committed May 1, 2023
1 parent 71a36fa commit 49b8f0f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/libtsduck/base/network/tsPcapFile.cpp
Expand Up @@ -269,7 +269,7 @@ bool ts::PcapFile::analyzeNgInterface(const uint8_t* data, size_t size, Report&
}
else if (tag == PCAPNG_IF_TSRESOL && len == 1) {
if ((data[0] & 0x80) == 0) {
ifd.time_units = Power10<SubSecond>(data[0]);
ifd.time_units = Power10(data[0]);
}
else {
ifd.time_units = TS_UCONST64(1) << (data[0] & 0x7F);
Expand Down
2 changes: 1 addition & 1 deletion src/libtsduck/base/types/tsBufferTemplate.h
Expand Up @@ -280,7 +280,7 @@ bool ts::Buffer::putBCD(INT value, size_t bcd_count)
if (bcd_count > 0) {
typedef typename std::make_unsigned<INT>::type UNSINT;
UNSINT uvalue = static_cast<UNSINT>(value);
UNSINT factor = Power10<UNSINT>(bcd_count);
UNSINT factor = static_cast<UNSINT>(Power10(bcd_count));
while (bcd_count-- > 0) {
uvalue %= factor;
factor /= 10;
Expand Down
3 changes: 1 addition & 2 deletions src/libtsduck/base/types/tsIntegerUtils.cpp
Expand Up @@ -81,8 +81,7 @@ size_t ts::MaxHexaWidth(size_t typeSize, size_t digitSeparatorSize)
// Get a power of 10 using a fast lookup table.
//----------------------------------------------------------------------------

template<>
uint64_t ts::Power10<uint64_t>(size_t pow)
uint64_t ts::Power10(size_t pow)
{
// Assume that not integer type is larger than 64 bits => 10^19 is the largest unsigned value.
static constexpr size_t MAX_POW10 = 19;
Expand Down
9 changes: 1 addition & 8 deletions src/libtsduck/base/types/tsIntegerUtils.h
Expand Up @@ -648,18 +648,11 @@ namespace ts {
//!
//! Get a power of 10 using a fast lookup table.
//!
//! @tparam INT An integer type.
//! @param [in] pow The requested power of 10.
//! @return The requested power of 10. If the value is larger than the largest integer on
//! this platform, the result is undefined.
//!
template<typename INT, typename std::enable_if<std::is_integral<INT>::value>::type* = nullptr>
inline INT Power10(size_t pow) { return static_cast<INT>(Power10<uint64_t>(pow)); }

//! @cond nodoxygen
// Template specialization.
template<> TSDUCKDLL uint64_t Power10<uint64_t>(size_t pow);
//! @endcond
TSDUCKDLL uint64_t Power10(size_t pow);

//!
//! Static values of power of 10.
Expand Down
2 changes: 1 addition & 1 deletion src/libtsduck/tsVersion.h
Expand Up @@ -44,4 +44,4 @@
//!
//! TSDuck commit number (automatically updated by Git hooks).
//!
#define TS_COMMIT 3195
#define TS_COMMIT 3197
14 changes: 5 additions & 9 deletions src/utest/utestIntegerUtils.cpp
Expand Up @@ -254,15 +254,11 @@ void IntegerUtilsTest::testBitSize()

void IntegerUtilsTest::testPower10()
{
TSUNIT_EQUAL(1, ts::Power10<uint8_t>(0));
TSUNIT_EQUAL(1, ts::Power10<int>(0));
TSUNIT_EQUAL(10, ts::Power10<uint8_t>(1));
TSUNIT_EQUAL(10, ts::Power10<int>(1));
TSUNIT_EQUAL(100, ts::Power10<uint8_t>(2));
TSUNIT_EQUAL(100, ts::Power10<int>(2));
TSUNIT_EQUAL(1000000, ts::Power10<uint32_t>(6));
TSUNIT_EQUAL(1000000, ts::Power10<uint64_t>(6));
TSUNIT_EQUAL(TS_UCONST64(1000000000000000), ts::Power10<uint64_t>(15));
TSUNIT_EQUAL(1, ts::Power10(0));
TSUNIT_EQUAL(10, ts::Power10(1));
TSUNIT_EQUAL(100, ts::Power10(2));
TSUNIT_EQUAL(1000000, ts::Power10(6));
TSUNIT_EQUAL(TS_UCONST64(1000000000000000), ts::Power10(15));

TSUNIT_EQUAL(1, (ts::static_power10<uint8_t, 0>::value));
TSUNIT_EQUAL(1, (ts::static_power10<int, 0>::value));
Expand Down

0 comments on commit 49b8f0f

Please sign in to comment.