Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

Commit

Permalink
fix: add hash for flag_tag to compatible with gcc < 6.1 (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
levy5307 authored and hycdong committed Dec 28, 2020
1 parent 5124bde commit ecf037e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions include/dsn/utility/flags.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,16 @@ enum class flag_tag
FT_MUTABLE = 0, /** flag data is mutable */
};

// support std::hash with enum types is implemented since gcc 6.1
// so we should define hash for flag_tag to compatible with gcc < 6.1
namespace std {
template <>
struct hash<flag_tag>
{
size_t operator()(const flag_tag &t) const { return size_t(t); }
};
} // namespace std

// Example:
// DSN_DEFINE_string("core", filename, "my_file.txt", "The file to read");
// DSN_DEFINE_validator(filename, [](const char *fname){ return is_file(fname); });
Expand Down

0 comments on commit ecf037e

Please sign in to comment.