clang-tidy 8.0 を実行していますが、次の警告が表示されます。
constructor does not initialize these fields:
テンプレート化されたクラスで委任コンストラクターを使用する場合。これが私が抑制すべき誤検知であるかどうか、または実際に私のコードが間違っているかどうかを知りたいです。
問題のコード例は次のとおりです。
template<typename T>
class A
{
public:
explicit A(const std::size_t size) :
data_(nullptr),
data_size_(size)
{
// ...
}
explicit A(const std::vector<T>& b) :
A(b.size())
{
// ...
}
private:
T* data_;
std::size_t data_size_;
};
このコードで clang-tidy を実行すると:
clang-tidy-8 --checks=* test.cpp
とりわけ、私は得ます:
warning: constructor does not initialize these fields: data_ [cppcoreguidelines-pro-type-member-init]
explicit A(const std::vector<T>& b) : A(b.size()) {}
ただし、クラスからテンプレートを削除して通常のクラスにすると、そのようなエラーは発生しません。
テンプレート化されたクラスで委任コンストラクターを使用するときに欠けているものはありますか、それともこれは clang-tidy のバグですか?
ありがとう!