From 52eb957d4b153ad0295cdf5012422f183bd2e7cd Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 2 Jul 2014 15:42:25 +1000 Subject: [PATCH] build: convert c-style cast to c++ style --- extent.cpp | 2 +- fourcc.cpp | 16 ++++++++-------- guid.cpp | 16 ++++++++-------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/extent.cpp b/extent.cpp index d029b556..8316213f 100644 --- a/extent.cpp +++ b/extent.cpp @@ -56,7 +56,7 @@ extent::operator= (const extent &rhs) { template T extent::diameter (void) const { - return (T)sqrt (w * w + h * h); + return static_cast (sqrt (w * w + h * h)); } diff --git a/fourcc.cpp b/fourcc.cpp index 2c96646a..c5b81b1d 100644 --- a/fourcc.cpp +++ b/fourcc.cpp @@ -43,10 +43,10 @@ fourcc fourcc::from_string (const char data[4]) { fourcc lhs; - lhs.data[0] = (uint8_t)data[0]; - lhs.data[1] = (uint8_t)data[1]; - lhs.data[2] = (uint8_t)data[2]; - lhs.data[3] = (uint8_t)data[3]; + lhs.data[0] = static_cast (data[0]); + lhs.data[1] = static_cast (data[1]); + lhs.data[2] = static_cast (data[2]); + lhs.data[3] = static_cast (data[3]); return lhs; } @@ -62,10 +62,10 @@ fourcc::operator== (const char rhs[4]) const { fourcc::operator uint32_t (void) const { - return (uint32_t)(data[0] << 24U | - data[1] << 16U | - data[2] << 8U | - data[3]); + return static_cast (data[0] << 24U | + data[1] << 16U | + data[2] << 8U | + data[3]); } diff --git a/guid.cpp b/guid.cpp index ffb22ab2..b0f862a3 100644 --- a/guid.cpp +++ b/guid.cpp @@ -156,14 +156,14 @@ guid::operator== (const guid &rhs) const { std::ostream& operator<< (std::ostream &os, const guid &g) { - uint64_t data4_b = (uint64_t)g.data4[0] << 0 | - (uint64_t)g.data4[1] << 8 | - (uint64_t)g.data4[2] << 16 | - (uint64_t)g.data4[3] << 24 | - (uint64_t)g.data4[4] << 32 | - (uint64_t)g.data4[5] << 40; - uint16_t data4_a = (uint16_t)g.data4[6] << 0 | - (uint16_t)g.data4[7] << 8; + uint64_t data4_b = static_cast (g.data4[0]) << 0u | + static_cast (g.data4[1]) << 8u | + static_cast (g.data4[2]) << 16u | + static_cast (g.data4[3]) << 24u | + static_cast (g.data4[4]) << 32u | + static_cast (g.data4[5]) << 40u; + uint16_t data4_a = static_cast (g.data4[6]) << 0u | + static_cast (g.data4[7]) << 8u; os << hex << setfill ('0') << setw (2 * sizeof (g.data1)) << g.data1 << "-" << setw (2 * sizeof (g.data2)) << g.data2 << "-"