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>
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;