Skip to content

Commit

Permalink
Fix compiler error + lint
Browse files Browse the repository at this point in the history
  • Loading branch information
hcho3 committed Nov 1, 2018
1 parent a4aa22e commit ba924a4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/common/enum_class_param.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,18 @@

// specialization of FieldEntry for enum class (backed by int)
#define DECLARE_FIELD_ENUM_CLASS(EnumClass) \
namespace dmlc { \
namespace parameter { \
template <> \
class dmlc::parameter::FieldEntry< EnumClass > \
: public dmlc::parameter::FieldEntry<int> { \
class FieldEntry<EnumClass> : public FieldEntry<int> { \
public: \
FieldEntry<EnumClass>() { \
static_assert( \
std::is_same<int, typename std::underlying_type<EnumClass>::type>::value, \
"enum class must be backed by int"); \
is_enum_ = true; \
} \
typedef FieldEntry<int> Super; \
using Super = FieldEntry<int>; \
void Set(void *head, const std::string &value) const override { \
Super::Set(head, value); \
} \
Expand All @@ -37,9 +38,12 @@ class dmlc::parameter::FieldEntry< EnumClass > \
has_default_ = true; \
return *this; \
} \
/* NOLINTNEXTLINE */ \
inline void Init(const std::string &key, void *head, EnumClass& ref) { \
Super::Init(key, head, *reinterpret_cast<int*>(&ref)); \
} \
};
}; \
} /* namespace parameter */ \
} /* namespace dmlc */

#endif // XGBOOST_COMMON_ENUM_CLASS_PARAM_H_

0 comments on commit ba924a4

Please sign in to comment.