streamed_mutation: fix non-POD argument to C-style variadic function

Clang warns that passing a non-POD to a C-style variadic function will
result in an abort().  That happens to be exactly what we want, but to
silence the warning, use a template instead.  Since templates aren't
allowed in local classes, move the containing class to namespace scope.
This commit is contained in:
Avi Kivity
2017-04-17 22:54:03 +03:00
parent 635c32eb32
commit f0c25fc20f

View File

@@ -88,14 +88,20 @@ void mutation_fragment::destroy_data() noexcept
}
}
namespace {
struct get_key_visitor {
const clustering_key_prefix& operator()(const clustering_row& cr) { return cr.key(); }
const clustering_key_prefix& operator()(const range_tombstone& rt) { return rt.start; }
template <typename T>
const clustering_key_prefix& operator()(const T&) { abort(); }
};
}
const clustering_key_prefix& mutation_fragment::key() const
{
assert(has_key());
struct get_key_visitor {
const clustering_key_prefix& operator()(const clustering_row& cr) { return cr.key(); }
const clustering_key_prefix& operator()(const range_tombstone& rt) { return rt.start; }
const clustering_key_prefix& operator()(...) { abort(); }
};
return visit(get_key_visitor());
}