]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/config: don't do aggregate initialization
authorKefu Chai <kchai@redhat.com>
Wed, 6 Feb 2019 16:41:43 +0000 (00:41 +0800)
committerKefu Chai <kchai@redhat.com>
Thu, 7 Feb 2019 07:35:16 +0000 (15:35 +0800)
in C++17, the base class subobject itself is an element of the
aggregation. by calling `get_size_visitor<T>{}`, we are using
aggregation-initialization of the derived class of
`boost::static_visitor` which defines its ctor and dtor as protected
member methods. and for aggregation-initialization, the base class
subobjects are treated exactly the same as member variables. so, we are
calling the protected member methods of `boost::static_visitor` via
`get_size_visitor<T>{}`. one way to do this, is to explicitly define the
ctor of `get_size_visitor`. or avoid using aggregation-initialization.

as list initialization is encouraged under most circumstances, for
instance,

- it does not allow narrowing.
- it is not ambiguous in the sense that it cannot be parsed as a
function declaration.

so, in this change, an empty constructor is added.

Signed-off-by: Kefu Chai <kchai@redhat.com>
src/common/config.cc

index d9a69f94c2c526ac231a29d50571df1e0c1a32b1..1f965b35363bb832d626c3502b90b65913bacb4b 100644 (file)
@@ -1341,6 +1341,8 @@ namespace {
 template<typename Size>
 struct get_size_visitor : public boost::static_visitor<Size>
 {
+  get_size_visitor() {}
+
   template<typename T>
   Size operator()(const T&) const {
     return -1;