Upgrade clang-tidy on CI. (#5469)
* Correct all clang-tidy errors. * Upgrade clang-tidy to 10 on CI. Co-authored-by: Hyunsu Cho <chohyu01@cs.washington.edu>
This commit is contained in:
@@ -106,7 +106,7 @@ using bst_uint = uint32_t; // NOLINT
|
||||
/*! \brief integer type. */
|
||||
using bst_int = int32_t; // NOLINT
|
||||
/*! \brief unsigned long integers */
|
||||
using bst_ulong = uint64_t;
|
||||
using bst_ulong = uint64_t; // NOLINT
|
||||
/*! \brief float type, used for storing statistics */
|
||||
using bst_float = float; // NOLINT
|
||||
|
||||
|
||||
@@ -42,34 +42,34 @@ class MetaInfo {
|
||||
static constexpr uint64_t kNumField = 9;
|
||||
|
||||
/*! \brief number of rows in the data */
|
||||
uint64_t num_row_{0};
|
||||
uint64_t num_row_{0}; // NOLINT
|
||||
/*! \brief number of columns in the data */
|
||||
uint64_t num_col_{0};
|
||||
uint64_t num_col_{0}; // NOLINT
|
||||
/*! \brief number of nonzero entries in the data */
|
||||
uint64_t num_nonzero_{0};
|
||||
uint64_t num_nonzero_{0}; // NOLINT
|
||||
/*! \brief label of each instance */
|
||||
HostDeviceVector<bst_float> labels_;
|
||||
HostDeviceVector<bst_float> labels_; // NOLINT
|
||||
/*!
|
||||
* \brief the index of begin and end of a group
|
||||
* needed when the learning task is ranking.
|
||||
*/
|
||||
std::vector<bst_group_t> group_ptr_;
|
||||
std::vector<bst_group_t> group_ptr_; // NOLINT
|
||||
/*! \brief weights of each instance, optional */
|
||||
HostDeviceVector<bst_float> weights_;
|
||||
HostDeviceVector<bst_float> weights_; // NOLINT
|
||||
/*!
|
||||
* \brief initialized margins,
|
||||
* if specified, xgboost will start from this init margin
|
||||
* can be used to specify initial prediction to boost from.
|
||||
*/
|
||||
HostDeviceVector<bst_float> base_margin_;
|
||||
HostDeviceVector<bst_float> base_margin_; // NOLINT
|
||||
/*!
|
||||
* \brief lower bound of the label, to be used for survival analysis (censored regression)
|
||||
*/
|
||||
HostDeviceVector<bst_float> labels_lower_bound_;
|
||||
HostDeviceVector<bst_float> labels_lower_bound_; // NOLINT
|
||||
/*!
|
||||
* \brief upper bound of the label, to be used for survival analysis (censored regression)
|
||||
*/
|
||||
HostDeviceVector<bst_float> labels_upper_bound_;
|
||||
HostDeviceVector<bst_float> labels_upper_bound_; // NOLINT
|
||||
|
||||
/*! \brief default constructor */
|
||||
MetaInfo() = default;
|
||||
@@ -360,7 +360,7 @@ class BatchIteratorImpl {
|
||||
template<typename T>
|
||||
class BatchIterator {
|
||||
public:
|
||||
using iterator_category = std::forward_iterator_tag;
|
||||
using iterator_category = std::forward_iterator_tag; // NOLINT
|
||||
explicit BatchIterator(BatchIteratorImpl<T>* impl) { impl_.reset(impl); }
|
||||
|
||||
void operator++() {
|
||||
@@ -395,9 +395,9 @@ class BatchIterator {
|
||||
template<typename T>
|
||||
class BatchSet {
|
||||
public:
|
||||
explicit BatchSet(BatchIterator<T> begin_iter) : begin_iter_(begin_iter) {}
|
||||
BatchIterator<T> begin() { return begin_iter_; }
|
||||
BatchIterator<T> end() { return BatchIterator<T>(nullptr); }
|
||||
explicit BatchSet(BatchIterator<T> begin_iter) : begin_iter_(std::move(begin_iter)) {}
|
||||
BatchIterator<T> begin() { return begin_iter_; } // NOLINT
|
||||
BatchIterator<T> end() { return BatchIterator<T>(nullptr); } // NOLINT
|
||||
|
||||
private:
|
||||
BatchIterator<T> begin_iter_;
|
||||
|
||||
@@ -65,7 +65,7 @@ class FeatureMap {
|
||||
return names_[idx].c_str();
|
||||
}
|
||||
/*! \return type of specific feature */
|
||||
Type type(size_t idx) const {
|
||||
Type TypeOf(size_t idx) const {
|
||||
CHECK_LT(idx, names_.size()) << "FeatureMap feature index exceed bound";
|
||||
return types_[idx];
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ struct GenericParameter : public XGBoostParameter<GenericParameter> {
|
||||
|
||||
private:
|
||||
// number of devices to use (deprecated).
|
||||
int n_gpus {0};
|
||||
int n_gpus {0}; // NOLINT
|
||||
};
|
||||
} // namespace xgboost
|
||||
|
||||
|
||||
@@ -130,7 +130,7 @@ class HostDeviceVector {
|
||||
|
||||
void Resize(size_t new_size, T v = T());
|
||||
|
||||
using value_type = T;
|
||||
using value_type = T; // NOLINT
|
||||
|
||||
private:
|
||||
HostDeviceVectorImpl<T>* impl_;
|
||||
|
||||
@@ -24,13 +24,13 @@ class Value {
|
||||
public:
|
||||
/*!\brief Simplified implementation of LLVM RTTI. */
|
||||
enum class ValueKind {
|
||||
String,
|
||||
Number,
|
||||
Integer,
|
||||
Object, // std::map
|
||||
Array, // std::vector
|
||||
Boolean,
|
||||
Null
|
||||
kString,
|
||||
kNumber,
|
||||
kInteger,
|
||||
kObject, // std::map
|
||||
kArray, // std::vector
|
||||
kBoolean,
|
||||
kNull
|
||||
};
|
||||
|
||||
explicit Value(ValueKind _kind) : kind_{_kind} {}
|
||||
@@ -54,7 +54,7 @@ class Value {
|
||||
|
||||
template <typename T>
|
||||
bool IsA(Value const* value) {
|
||||
return T::isClassOf(value);
|
||||
return T::IsClassOf(value);
|
||||
}
|
||||
|
||||
template <typename T, typename U>
|
||||
@@ -70,26 +70,26 @@ T* Cast(U* value) {
|
||||
class JsonString : public Value {
|
||||
std::string str_;
|
||||
public:
|
||||
JsonString() : Value(ValueKind::String) {}
|
||||
JsonString() : Value(ValueKind::kString) {}
|
||||
JsonString(std::string const& str) : // NOLINT
|
||||
Value(ValueKind::String), str_{str} {}
|
||||
Value(ValueKind::kString), str_{str} {}
|
||||
JsonString(std::string&& str) : // NOLINT
|
||||
Value(ValueKind::String), str_{std::move(str)} {}
|
||||
Value(ValueKind::kString), str_{std::move(str)} {}
|
||||
|
||||
void Save(JsonWriter* writer) override;
|
||||
|
||||
Json& operator[](std::string const & key) override;
|
||||
Json& operator[](int ind) override;
|
||||
|
||||
std::string const& getString() && { return str_; }
|
||||
std::string const& getString() const & { return str_; }
|
||||
std::string& getString() & { return str_; }
|
||||
std::string const& GetString() && { return str_; }
|
||||
std::string const& GetString() const & { return str_; }
|
||||
std::string& GetString() & { return str_; }
|
||||
|
||||
bool operator==(Value const& rhs) const override;
|
||||
Value& operator=(Value const& rhs) override;
|
||||
|
||||
static bool isClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::String;
|
||||
static bool IsClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::kString;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -97,11 +97,11 @@ class JsonArray : public Value {
|
||||
std::vector<Json> vec_;
|
||||
|
||||
public:
|
||||
JsonArray() : Value(ValueKind::Array) {}
|
||||
JsonArray() : Value(ValueKind::kArray) {}
|
||||
JsonArray(std::vector<Json>&& arr) : // NOLINT
|
||||
Value(ValueKind::Array), vec_{std::move(arr)} {}
|
||||
Value(ValueKind::kArray), vec_{std::move(arr)} {}
|
||||
JsonArray(std::vector<Json> const& arr) : // NOLINT
|
||||
Value(ValueKind::Array), vec_{arr} {}
|
||||
Value(ValueKind::kArray), vec_{arr} {}
|
||||
JsonArray(JsonArray const& that) = delete;
|
||||
JsonArray(JsonArray && that);
|
||||
|
||||
@@ -110,15 +110,15 @@ class JsonArray : public Value {
|
||||
Json& operator[](std::string const & key) override;
|
||||
Json& operator[](int ind) override;
|
||||
|
||||
std::vector<Json> const& getArray() && { return vec_; }
|
||||
std::vector<Json> const& getArray() const & { return vec_; }
|
||||
std::vector<Json>& getArray() & { return vec_; }
|
||||
std::vector<Json> const& GetArray() && { return vec_; }
|
||||
std::vector<Json> const& GetArray() const & { return vec_; }
|
||||
std::vector<Json>& GetArray() & { return vec_; }
|
||||
|
||||
bool operator==(Value const& rhs) const override;
|
||||
Value& operator=(Value const& rhs) override;
|
||||
|
||||
static bool isClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::Array;
|
||||
static bool IsClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::kArray;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -126,7 +126,7 @@ class JsonObject : public Value {
|
||||
std::map<std::string, Json> object_;
|
||||
|
||||
public:
|
||||
JsonObject() : Value(ValueKind::Object) {}
|
||||
JsonObject() : Value(ValueKind::kObject) {}
|
||||
JsonObject(std::map<std::string, Json>&& object); // NOLINT
|
||||
JsonObject(JsonObject const& that) = delete;
|
||||
JsonObject(JsonObject && that);
|
||||
@@ -136,17 +136,17 @@ class JsonObject : public Value {
|
||||
Json& operator[](std::string const & key) override;
|
||||
Json& operator[](int ind) override;
|
||||
|
||||
std::map<std::string, Json> const& getObject() && { return object_; }
|
||||
std::map<std::string, Json> const& getObject() const & { return object_; }
|
||||
std::map<std::string, Json> & getObject() & { return object_; }
|
||||
std::map<std::string, Json> const& GetObject() && { return object_; }
|
||||
std::map<std::string, Json> const& GetObject() const & { return object_; }
|
||||
std::map<std::string, Json> & GetObject() & { return object_; }
|
||||
|
||||
bool operator==(Value const& rhs) const override;
|
||||
Value& operator=(Value const& rhs) override;
|
||||
|
||||
static bool isClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::Object;
|
||||
static bool IsClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::kObject;
|
||||
}
|
||||
virtual ~JsonObject() = default;
|
||||
~JsonObject() override = default;
|
||||
};
|
||||
|
||||
class JsonNumber : public Value {
|
||||
@@ -154,18 +154,18 @@ class JsonNumber : public Value {
|
||||
using Float = float;
|
||||
|
||||
private:
|
||||
Float number_;
|
||||
Float number_ { 0 };
|
||||
|
||||
public:
|
||||
JsonNumber() : Value(ValueKind::Number) {}
|
||||
JsonNumber() : Value(ValueKind::kNumber) {}
|
||||
template <typename FloatT,
|
||||
typename std::enable_if<std::is_same<FloatT, Float>::value>::type* = nullptr>
|
||||
JsonNumber(FloatT value) : Value(ValueKind::Number) { // NOLINT
|
||||
JsonNumber(FloatT value) : Value(ValueKind::kNumber) { // NOLINT
|
||||
number_ = value;
|
||||
}
|
||||
template <typename FloatT,
|
||||
typename std::enable_if<std::is_same<FloatT, double>::value>::type* = nullptr>
|
||||
JsonNumber(FloatT value) : Value{ValueKind::Number}, // NOLINT
|
||||
JsonNumber(FloatT value) : Value{ValueKind::kNumber}, // NOLINT
|
||||
number_{static_cast<Float>(value)} {}
|
||||
|
||||
void Save(JsonWriter* writer) override;
|
||||
@@ -173,16 +173,16 @@ class JsonNumber : public Value {
|
||||
Json& operator[](std::string const & key) override;
|
||||
Json& operator[](int ind) override;
|
||||
|
||||
Float const& getNumber() && { return number_; }
|
||||
Float const& getNumber() const & { return number_; }
|
||||
Float& getNumber() & { return number_; }
|
||||
Float const& GetNumber() && { return number_; }
|
||||
Float const& GetNumber() const & { return number_; }
|
||||
Float& GetNumber() & { return number_; }
|
||||
|
||||
|
||||
bool operator==(Value const& rhs) const override;
|
||||
Value& operator=(Value const& rhs) override;
|
||||
|
||||
static bool isClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::Number;
|
||||
static bool IsClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::kNumber;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -191,27 +191,27 @@ class JsonInteger : public Value {
|
||||
using Int = int64_t;
|
||||
|
||||
private:
|
||||
Int integer_;
|
||||
Int integer_ {0};
|
||||
|
||||
public:
|
||||
JsonInteger() : Value(ValueKind::Integer), integer_{0} {} // NOLINT
|
||||
JsonInteger() : Value(ValueKind::kInteger) {} // NOLINT
|
||||
template <typename IntT,
|
||||
typename std::enable_if<std::is_same<IntT, Int>::value>::type* = nullptr>
|
||||
JsonInteger(IntT value) : Value(ValueKind::Integer), integer_{value} {} // NOLINT
|
||||
JsonInteger(IntT value) : Value(ValueKind::kInteger), integer_{value} {} // NOLINT
|
||||
template <typename IntT,
|
||||
typename std::enable_if<std::is_same<IntT, size_t>::value>::type* = nullptr>
|
||||
JsonInteger(IntT value) : Value(ValueKind::Integer), // NOLINT
|
||||
JsonInteger(IntT value) : Value(ValueKind::kInteger), // NOLINT
|
||||
integer_{static_cast<Int>(value)} {}
|
||||
template <typename IntT,
|
||||
typename std::enable_if<std::is_same<IntT, int32_t>::value>::type* = nullptr>
|
||||
JsonInteger(IntT value) : Value(ValueKind::Integer), // NOLINT
|
||||
JsonInteger(IntT value) : Value(ValueKind::kInteger), // NOLINT
|
||||
integer_{static_cast<Int>(value)} {}
|
||||
template <typename IntT,
|
||||
typename std::enable_if<
|
||||
std::is_same<IntT, uint32_t>::value &&
|
||||
!std::is_same<std::size_t, uint32_t>::value>::type * = nullptr>
|
||||
JsonInteger(IntT value) // NOLINT
|
||||
: Value(ValueKind::Integer),
|
||||
: Value(ValueKind::kInteger),
|
||||
integer_{static_cast<Int>(value)} {}
|
||||
|
||||
Json& operator[](std::string const & key) override;
|
||||
@@ -220,20 +220,20 @@ class JsonInteger : public Value {
|
||||
bool operator==(Value const& rhs) const override;
|
||||
Value& operator=(Value const& rhs) override;
|
||||
|
||||
Int const& getInteger() && { return integer_; }
|
||||
Int const& getInteger() const & { return integer_; }
|
||||
Int& getInteger() & { return integer_; }
|
||||
Int const& GetInteger() && { return integer_; }
|
||||
Int const& GetInteger() const & { return integer_; }
|
||||
Int& GetInteger() & { return integer_; }
|
||||
void Save(JsonWriter* writer) override;
|
||||
|
||||
static bool isClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::Integer;
|
||||
static bool IsClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::kInteger;
|
||||
}
|
||||
};
|
||||
|
||||
class JsonNull : public Value {
|
||||
public:
|
||||
JsonNull() : Value(ValueKind::Null) {}
|
||||
JsonNull(std::nullptr_t) : Value(ValueKind::Null) {} // NOLINT
|
||||
JsonNull() : Value(ValueKind::kNull) {}
|
||||
JsonNull(std::nullptr_t) : Value(ValueKind::kNull) {} // NOLINT
|
||||
|
||||
void Save(JsonWriter* writer) override;
|
||||
|
||||
@@ -243,8 +243,8 @@ class JsonNull : public Value {
|
||||
bool operator==(Value const& rhs) const override;
|
||||
Value& operator=(Value const& rhs) override;
|
||||
|
||||
static bool isClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::Null;
|
||||
static bool IsClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::kNull;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -253,33 +253,34 @@ class JsonBoolean : public Value {
|
||||
bool boolean_;
|
||||
|
||||
public:
|
||||
JsonBoolean() : Value(ValueKind::Boolean) {} // NOLINT
|
||||
JsonBoolean() : Value(ValueKind::kBoolean) {} // NOLINT
|
||||
// Ambigious with JsonNumber.
|
||||
template <typename Bool,
|
||||
typename std::enable_if<
|
||||
std::is_same<Bool, bool>::value ||
|
||||
std::is_same<Bool, bool const>::value>::type* = nullptr>
|
||||
JsonBoolean(Bool value) : // NOLINT
|
||||
Value(ValueKind::Boolean), boolean_{value} {}
|
||||
Value(ValueKind::kBoolean), boolean_{value} {}
|
||||
|
||||
void Save(JsonWriter* writer) override;
|
||||
|
||||
Json& operator[](std::string const & key) override;
|
||||
Json& operator[](int ind) override;
|
||||
|
||||
bool const& getBoolean() && { return boolean_; }
|
||||
bool const& getBoolean() const & { return boolean_; }
|
||||
bool& getBoolean() & { return boolean_; }
|
||||
bool const& GetBoolean() && { return boolean_; }
|
||||
bool const& GetBoolean() const & { return boolean_; }
|
||||
bool& GetBoolean() & { return boolean_; }
|
||||
|
||||
bool operator==(Value const& rhs) const override;
|
||||
Value& operator=(Value const& rhs) override;
|
||||
|
||||
static bool isClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::Boolean;
|
||||
static bool IsClassOf(Value const* value) {
|
||||
return value->Type() == ValueKind::kBoolean;
|
||||
}
|
||||
};
|
||||
|
||||
struct StringView {
|
||||
private:
|
||||
using CharT = char; // unsigned char
|
||||
CharT const* str_;
|
||||
size_t size_;
|
||||
@@ -392,7 +393,7 @@ class Json {
|
||||
}
|
||||
|
||||
// copy
|
||||
Json(Json const& other) : ptr_{other.ptr_} {}
|
||||
Json(Json const& other) = default;
|
||||
Json& operator=(Json const& other);
|
||||
// move
|
||||
Json(Json&& other) : ptr_{std::move(other.ptr_)} {}
|
||||
@@ -439,13 +440,13 @@ template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonNumber>::value>::type* = nullptr>
|
||||
JsonNumber::Float& GetImpl(T& val) { // NOLINT
|
||||
return val.getNumber();
|
||||
return val.GetNumber();
|
||||
}
|
||||
template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonNumber const>::value>::type* = nullptr>
|
||||
JsonNumber::Float const& GetImpl(T& val) { // NOLINT
|
||||
return val.getNumber();
|
||||
return val.GetNumber();
|
||||
}
|
||||
|
||||
// Integer
|
||||
@@ -453,13 +454,13 @@ template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonInteger>::value>::type* = nullptr>
|
||||
JsonInteger::Int& GetImpl(T& val) { // NOLINT
|
||||
return val.getInteger();
|
||||
return val.GetInteger();
|
||||
}
|
||||
template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonInteger const>::value>::type* = nullptr>
|
||||
JsonInteger::Int const& GetImpl(T& val) { // NOLINT
|
||||
return val.getInteger();
|
||||
return val.GetInteger();
|
||||
}
|
||||
|
||||
// String
|
||||
@@ -467,13 +468,13 @@ template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonString>::value>::type* = nullptr>
|
||||
std::string& GetImpl(T& val) { // NOLINT
|
||||
return val.getString();
|
||||
return val.GetString();
|
||||
}
|
||||
template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonString const>::value>::type* = nullptr>
|
||||
std::string const& GetImpl(T& val) { // NOLINT
|
||||
return val.getString();
|
||||
return val.GetString();
|
||||
}
|
||||
|
||||
// Boolean
|
||||
@@ -481,13 +482,13 @@ template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonBoolean>::value>::type* = nullptr>
|
||||
bool& GetImpl(T& val) { // NOLINT
|
||||
return val.getBoolean();
|
||||
return val.GetBoolean();
|
||||
}
|
||||
template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonBoolean const>::value>::type* = nullptr>
|
||||
bool const& GetImpl(T& val) { // NOLINT
|
||||
return val.getBoolean();
|
||||
return val.GetBoolean();
|
||||
}
|
||||
|
||||
// Array
|
||||
@@ -495,13 +496,13 @@ template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonArray>::value>::type* = nullptr>
|
||||
std::vector<Json>& GetImpl(T& val) { // NOLINT
|
||||
return val.getArray();
|
||||
return val.GetArray();
|
||||
}
|
||||
template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonArray const>::value>::type* = nullptr>
|
||||
std::vector<Json> const& GetImpl(T& val) { // NOLINT
|
||||
return val.getArray();
|
||||
return val.GetArray();
|
||||
}
|
||||
|
||||
// Object
|
||||
@@ -509,13 +510,13 @@ template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonObject>::value>::type* = nullptr>
|
||||
std::map<std::string, Json>& GetImpl(T& val) { // NOLINT
|
||||
return val.getObject();
|
||||
return val.GetObject();
|
||||
}
|
||||
template <typename T,
|
||||
typename std::enable_if<
|
||||
std::is_same<T, JsonObject const>::value>::type* = nullptr>
|
||||
std::map<std::string, Json> const& GetImpl(T& val) { // NOLINT
|
||||
return val.getObject();
|
||||
return val.GetObject();
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
@@ -545,7 +546,7 @@ using Null = JsonNull;
|
||||
// Utils tailored for XGBoost.
|
||||
|
||||
template <typename Parameter>
|
||||
Object toJson(Parameter const& param) {
|
||||
Object ToJson(Parameter const& param) {
|
||||
Object obj;
|
||||
for (auto const& kv : param.__DICT__()) {
|
||||
obj[kv.first] = kv.second;
|
||||
@@ -554,7 +555,7 @@ Object toJson(Parameter const& param) {
|
||||
}
|
||||
|
||||
template <typename Parameter>
|
||||
void fromJson(Json const& obj, Parameter* param) {
|
||||
void FromJson(Json const& obj, Parameter* param) {
|
||||
auto const& j_param = get<Object const>(obj);
|
||||
std::map<std::string, std::string> m;
|
||||
for (auto const& kv : j_param) {
|
||||
|
||||
@@ -38,10 +38,11 @@ class JsonReader {
|
||||
std::numeric_limits<double>::max_digits10 + 1;
|
||||
|
||||
struct SourceLocation {
|
||||
size_t pos_; // current position in raw_str_
|
||||
private:
|
||||
size_t pos_ { 0 }; // current position in raw_str_
|
||||
|
||||
public:
|
||||
SourceLocation() : pos_(0) {}
|
||||
SourceLocation() = default;
|
||||
size_t Pos() const { return pos_; }
|
||||
|
||||
SourceLocation& Forward() {
|
||||
|
||||
@@ -234,13 +234,13 @@ struct LearnerModelParamLegacy;
|
||||
*/
|
||||
struct LearnerModelParam {
|
||||
/* \brief global bias */
|
||||
bst_float base_score;
|
||||
bst_float base_score { 0.5f };
|
||||
/* \brief number of features */
|
||||
uint32_t num_feature;
|
||||
uint32_t num_feature { 0 };
|
||||
/* \brief number of classes, if it is multi-class classification */
|
||||
uint32_t num_output_group;
|
||||
uint32_t num_output_group { 0 };
|
||||
|
||||
LearnerModelParam() : base_score {0.5}, num_feature{0}, num_output_group{0} {}
|
||||
LearnerModelParam() = default;
|
||||
// As the old `LearnerModelParamLegacy` is still used by binary IO, we keep
|
||||
// this one as an immutable copy.
|
||||
LearnerModelParam(LearnerModelParamLegacy const& user_param, float base_margin);
|
||||
|
||||
@@ -33,7 +33,7 @@ class LinearUpdater : public Configurable {
|
||||
|
||||
public:
|
||||
/*! \brief virtual destructor */
|
||||
virtual ~LinearUpdater() = default;
|
||||
~LinearUpdater() override = default;
|
||||
/*!
|
||||
* \brief Initialize the updater with given arguments.
|
||||
* \param args arguments to the objective function.
|
||||
|
||||
@@ -41,14 +41,14 @@ class Metric : public Configurable {
|
||||
* override this function to maintain internal configuration
|
||||
* \param in JSON object containing the configuration
|
||||
*/
|
||||
virtual void LoadConfig(Json const& in) {}
|
||||
void LoadConfig(Json const& in) override {}
|
||||
/*!
|
||||
* \brief Save configuration to JSON object
|
||||
* By default, metric has no internal configuration;
|
||||
* override this function to maintain internal configuration
|
||||
* \param out pointer to output JSON object
|
||||
*/
|
||||
virtual void SaveConfig(Json* out) const {}
|
||||
void SaveConfig(Json* out) const override {}
|
||||
|
||||
/*!
|
||||
* \brief evaluate a specific metric
|
||||
@@ -64,7 +64,7 @@ class Metric : public Configurable {
|
||||
/*! \return name of metric */
|
||||
virtual const char* Name() const = 0;
|
||||
/*! \brief virtual destructor */
|
||||
virtual ~Metric() = default;
|
||||
~Metric() override = default;
|
||||
/*!
|
||||
* \brief create a metric according to name.
|
||||
* \param name name of the metric.
|
||||
|
||||
@@ -28,7 +28,7 @@ class ObjFunction : public Configurable {
|
||||
|
||||
public:
|
||||
/*! \brief virtual destructor */
|
||||
virtual ~ObjFunction() = default;
|
||||
~ObjFunction() override = default;
|
||||
/*!
|
||||
* \brief Configure the objective with the specified parameters.
|
||||
* \param args arguments to the objective function.
|
||||
|
||||
@@ -36,11 +36,11 @@ struct PredictionCacheEntry {
|
||||
// A storage for caching prediction values
|
||||
HostDeviceVector<bst_float> predictions;
|
||||
// The version of current cache, corresponding number of layers of trees
|
||||
uint32_t version;
|
||||
uint32_t version { 0 };
|
||||
// A weak pointer for checking whether the DMatrix object has expired.
|
||||
std::weak_ptr< DMatrix > ref;
|
||||
|
||||
PredictionCacheEntry() : version { 0 } {}
|
||||
PredictionCacheEntry() = default;
|
||||
/* \brief Update the cache entry by number of versions.
|
||||
*
|
||||
* \param v Added versions.
|
||||
|
||||
@@ -105,8 +105,9 @@ namespace detail {
|
||||
* represent ptrdiff_t, which is just int64_t. So we make it determinstic
|
||||
* here.
|
||||
*/
|
||||
using ptrdiff_t = typename std::conditional<std::is_same<std::ptrdiff_t, std::int64_t>::value,
|
||||
std::ptrdiff_t, std::int64_t>::type;
|
||||
using ptrdiff_t = typename std::conditional< // NOLINT
|
||||
std::is_same<std::ptrdiff_t, std::int64_t>::value,
|
||||
std::ptrdiff_t, std::int64_t>::type;
|
||||
} // namespace detail
|
||||
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1910
|
||||
@@ -136,7 +137,7 @@ class SpanIterator {
|
||||
IsConst, const ElementType, ElementType>::type&;
|
||||
using pointer = typename std::add_pointer<reference>::type; // NOLINT
|
||||
|
||||
XGBOOST_DEVICE constexpr SpanIterator() : span_{nullptr}, index_{0} {}
|
||||
constexpr SpanIterator() = default;
|
||||
|
||||
XGBOOST_DEVICE constexpr SpanIterator(
|
||||
const SpanType* _span,
|
||||
@@ -243,8 +244,8 @@ class SpanIterator {
|
||||
}
|
||||
|
||||
protected:
|
||||
const SpanType *span_;
|
||||
typename SpanType::index_type index_;
|
||||
const SpanType *span_ { nullptr };
|
||||
typename SpanType::index_type index_ { 0 };
|
||||
};
|
||||
|
||||
|
||||
@@ -409,8 +410,7 @@ class Span {
|
||||
using const_reverse_iterator = const detail::SpanIterator<Span<T, Extent>, true>; // NOLINT
|
||||
|
||||
// constructors
|
||||
|
||||
XGBOOST_DEVICE constexpr Span() __span_noexcept : size_(0), data_(nullptr) {}
|
||||
constexpr Span() __span_noexcept = default;
|
||||
|
||||
XGBOOST_DEVICE Span(pointer _ptr, index_type _count) :
|
||||
size_(_count), data_(_ptr) {
|
||||
@@ -503,11 +503,11 @@ class Span {
|
||||
|
||||
// element access
|
||||
|
||||
XGBOOST_DEVICE reference front() const {
|
||||
XGBOOST_DEVICE reference front() const { // NOLINT
|
||||
return (*this)[0];
|
||||
}
|
||||
|
||||
XGBOOST_DEVICE reference back() const {
|
||||
XGBOOST_DEVICE reference back() const { // NOLINT
|
||||
return (*this)[size() - 1];
|
||||
}
|
||||
|
||||
@@ -587,8 +587,8 @@ class Span {
|
||||
}
|
||||
|
||||
private:
|
||||
index_type size_;
|
||||
pointer data_;
|
||||
index_type size_ { 0 };
|
||||
pointer data_ { nullptr };
|
||||
};
|
||||
|
||||
template <class T, std::size_t X, class U, std::size_t Y>
|
||||
|
||||
@@ -34,7 +34,7 @@ class TreeUpdater : public Configurable {
|
||||
|
||||
public:
|
||||
/*! \brief virtual destructor */
|
||||
virtual ~TreeUpdater() = default;
|
||||
~TreeUpdater() override = default;
|
||||
/*!
|
||||
* \brief Initialize the updater with given arguments.
|
||||
* \param args arguments to the objective function.
|
||||
|
||||
Reference in New Issue
Block a user