Skip to content

Commit

Permalink
Use static_cast for hash.
Browse files Browse the repository at this point in the history
  • Loading branch information
spahrenk committed Feb 23, 2024
1 parent eae1dd3 commit e384b6b
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@
#include <cstdlib> //for exit
#include <vector>
#include <unordered_map>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <type_traits>
#include <utility>

namespace Btwxt
{
Expand Down Expand Up @@ -267,8 +272,8 @@ class HPWH
template <class T>
std::size_t operator()(const std::pair<T, T>& p) const
{
auto h1 = std::hash<T> {}(p.first);
auto h2 = std::hash<T> {}(p.second);
auto h1 = static_cast<std::size_t>(p.first);
auto h2 = static_cast<std::size_t>(p.second);
return h1 ^ h2;
}
};
Expand All @@ -284,6 +289,7 @@ class HPWH
MIN, // minutes
S // seconds
};

static ConversionMap<TIME_UNITS> convertTime;
inline static double
convert(const double time, const HPWH::TIME_UNITS fromUnits, const HPWH::TIME_UNITS toUnits)
Expand Down Expand Up @@ -311,7 +317,7 @@ class HPWH
}

/* energy units and conversion */
enum class E_UNITS
enum class E_UNITS:std::size_t
{
KJ, // kilojoules
KWH, // kilowatt hours
Expand All @@ -325,7 +331,7 @@ class HPWH
}

/* power units and conversion */
enum class P_UNITS
enum class P_UNITS:std::size_t
{
KW, // kilowatts
BTUperH, // BTU per hour
Expand Down

0 comments on commit e384b6b

Please sign in to comment.