Files
scylladb/idl/range.idl.hh
Avi Kivity f3dccc2215 interval: change start()/end() not to return references to data members
We'd like to change the data layout of `interval` to save space.
As a result, start() and end() which return references to data
members must return objects (not references). Since we'd like
to maintain zero-copy for these functions, we change them to
return objects containing references (rather than references
to objects), avoiding copying of potentially expensive objects.

We repurpose the interval_bound class to hold references (by
instantiating it with `const T&` instead of `T`) and provide
converting constructors. To make transform_bounds() retain
zero-copy, we add start() and end() that take *this by
rvalue reference.
2025-06-14 21:26:17 +03:00

28 lines
548 B
C++

/*
* Copyright 2016-present ScyllaDB
*/
/*
* SPDX-License-Identifier: LicenseRef-ScyllaDB-Source-Available-1.0
*/
template<typename T>
class interval_bound {
T value();
bool is_inclusive();
};
template<typename T>
class wrapping_interval {
std::optional<interval_bound<T>> start_copy();
std::optional<interval_bound<T>> end_copy();
bool is_singular();
};
template<typename T>
class interval {
std::optional<interval_bound<T>> start_copy();
std::optional<interval_bound<T>> end_copy();
bool is_singular();
};