Skip to content

Commit 58b940a

Browse files
authored
Merge pull request ceph#63001 from tchaikov/librbd-tools-std-variant
librbd, tools: migrate from boost::variant to std::variant Reviewed-by: Ilya Dryomov <[email protected]>
2 parents afd3f6b + 786ea20 commit 58b940a

33 files changed

+123
-134
lines changed

src/librbd/MirroringWatcher.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ void MirroringWatcher<I>::handle_notify(uint64_t notify_id, uint64_t handle,
108108
return;
109109
}
110110

111-
apply_visitor(watcher::util::HandlePayloadVisitor<MirroringWatcher<I>>(
112-
this, notify_id, handle), notify_message.payload);
111+
std::visit(watcher::util::HandlePayloadVisitor<MirroringWatcher<I>>(
112+
this, notify_id, handle), notify_message.payload);
113113
}
114114

115115
template <typename I>

src/librbd/TrashWatcher.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ void TrashWatcher<I>::handle_notify(uint64_t notify_id, uint64_t handle,
8383
return;
8484
}
8585

86-
apply_visitor(watcher::util::HandlePayloadVisitor<TrashWatcher<I>>(
86+
std::visit(watcher::util::HandlePayloadVisitor<TrashWatcher<I>>(
8787
this, notify_id, handle), notify_message.payload);
8888
}
8989

src/librbd/WatchNotifyTypes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#include <list>
1313
#include <memory>
1414
#include <string>
15-
#include <boost/variant.hpp>
1615

1716
namespace ceph {
1817
class Formatter;

src/librbd/api/Snapshot.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
#include "include/Context.h"
1414
#include "common/Cond.h"
1515

16-
#include <boost/variant.hpp>
17-
1816
#include <shared_mutex> // for std::shared_lock
1917

2018
#define dout_subsys ceph_subsys_rbd

src/librbd/io/ImageDispatchSpec.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
#include "librbd/io/AioCompletion.h"
77
#include "librbd/io/ImageRequest.h"
88
#include "librbd/io/ImageDispatcherInterface.h"
9-
#include <boost/variant.hpp>
109

1110
namespace librbd {
1211
namespace io {

src/librbd/io/ObjectDispatchSpec.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "librbd/io/ObjectDispatchSpec.h"
55
#include "include/Context.h"
66
#include "librbd/io/ObjectDispatcherInterface.h"
7-
#include <boost/variant.hpp>
87

98
namespace librbd {
109
namespace io {

src/librbd/io/ObjectDispatchSpec.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "common/zipkin_trace.h"
1212
#include "librbd/Types.h"
1313
#include "librbd/io/Types.h"
14-
#include <boost/variant/variant.hpp>
14+
#include <variant>
1515

1616
namespace librbd {
1717
namespace io {
@@ -144,13 +144,13 @@ struct ObjectDispatchSpec {
144144
}
145145
};
146146

147-
typedef boost::variant<ReadRequest,
148-
DiscardRequest,
149-
WriteRequest,
150-
WriteSameRequest,
151-
CompareAndWriteRequest,
152-
FlushRequest,
153-
ListSnapsRequest> Request;
147+
typedef std::variant<ReadRequest,
148+
DiscardRequest,
149+
WriteRequest,
150+
WriteSameRequest,
151+
CompareAndWriteRequest,
152+
FlushRequest,
153+
ListSnapsRequest> Request;
154154

155155
C_Dispatcher dispatcher_ctx;
156156

src/librbd/io/ObjectDispatcher.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "librbd/asio/ContextWQ.h"
1111
#include "librbd/io/ObjectDispatch.h"
1212
#include "librbd/io/ObjectDispatchSpec.h"
13-
#include <boost/variant.hpp>
1413

1514
#include <shared_mutex> // for std::shared_lock
1615

@@ -35,7 +34,7 @@ struct ObjectDispatcher<I>::C_ResetExistenceCache : public C_LayerIterator {
3534
};
3635

3736
template <typename I>
38-
struct ObjectDispatcher<I>::SendVisitor : public boost::static_visitor<bool> {
37+
struct ObjectDispatcher<I>::SendVisitor {
3938
ObjectDispatchInterface* object_dispatch;
4039
ObjectDispatchSpec* object_dispatch_spec;
4140

@@ -199,7 +198,7 @@ template <typename I>
199198
bool ObjectDispatcher<I>::send_dispatch(
200199
ObjectDispatchInterface* object_dispatch,
201200
ObjectDispatchSpec* object_dispatch_spec) {
202-
return boost::apply_visitor(
201+
return std::visit(
203202
SendVisitor{object_dispatch, object_dispatch_spec},
204203
object_dispatch_spec->request);
205204
}

src/librbd/io/ReadResult.cc

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include "common/dout.h"
77
#include "librbd/io/AioCompletion.h"
88
#include "librbd/io/Utils.h"
9-
#include <boost/variant/apply_visitor.hpp>
10-
#include <boost/variant/static_visitor.hpp>
119

1210
#define dout_subsys ceph_subsys_rbd
1311
#undef dout_prefix
@@ -17,7 +15,7 @@
1715
namespace librbd {
1816
namespace io {
1917

20-
struct ReadResult::SetImageExtentsVisitor : public boost::static_visitor<void> {
18+
struct ReadResult::SetImageExtentsVisitor {
2119
Extents image_extents;
2220

2321
explicit SetImageExtentsVisitor(const Extents& image_extents)
@@ -40,15 +38,15 @@ struct ReadResult::SetImageExtentsVisitor : public boost::static_visitor<void> {
4038
}
4139
};
4240

43-
struct ReadResult::AssembleResultVisitor : public boost::static_visitor<void> {
41+
struct ReadResult::AssembleResultVisitor {
4442
CephContext *cct;
4543
Striper::StripedReadResult &destriper;
4644

4745
AssembleResultVisitor(CephContext *cct, Striper::StripedReadResult &destriper)
4846
: cct(cct), destriper(destriper) {
4947
}
5048

51-
void operator()(Empty &empty) const {
49+
void operator()(std::monostate &empty) const {
5250
ldout(cct, 20) << "dropping read result" << dendl;
5351
}
5452

@@ -230,9 +228,6 @@ void ReadResult::C_ObjectReadMergedExtents::finish(int r) {
230228
on_finish->complete(r);
231229
}
232230

233-
ReadResult::ReadResult() : m_buffer(Empty()) {
234-
}
235-
236231
ReadResult::ReadResult(char *buf, size_t buf_len)
237232
: m_buffer(Linear(buf, buf_len)) {
238233
}
@@ -250,11 +245,11 @@ ReadResult::ReadResult(Extents* extent_map, ceph::bufferlist* bl)
250245
}
251246

252247
void ReadResult::set_image_extents(const Extents& image_extents) {
253-
boost::apply_visitor(SetImageExtentsVisitor(image_extents), m_buffer);
248+
std::visit(SetImageExtentsVisitor(image_extents), m_buffer);
254249
}
255250

256251
void ReadResult::assemble_result(CephContext *cct) {
257-
boost::apply_visitor(AssembleResultVisitor(cct, m_destriper), m_buffer);
252+
std::visit(AssembleResultVisitor(cct, m_destriper), m_buffer);
258253
}
259254

260255
} // namespace io

src/librbd/io/ReadResult.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "librbd/io/Types.h"
1212
#include "osdc/Striper.h"
1313
#include <sys/uio.h>
14-
#include <boost/variant/variant.hpp>
14+
#include <variant>
1515

1616

1717
namespace librbd {
@@ -60,7 +60,7 @@ class ReadResult {
6060
void finish(int r) override;
6161
};
6262

63-
ReadResult();
63+
ReadResult() = default;
6464
ReadResult(char *buf, size_t buf_len);
6565
ReadResult(const struct iovec *iov, int iov_count);
6666
ReadResult(ceph::bufferlist *bl);
@@ -71,9 +71,6 @@ class ReadResult {
7171
void assemble_result(CephContext *cct);
7272

7373
private:
74-
struct Empty {
75-
};
76-
7774
struct Linear {
7875
char *buf;
7976
size_t buf_len;
@@ -109,11 +106,11 @@ class ReadResult {
109106
}
110107
};
111108

112-
typedef boost::variant<Empty,
113-
Linear,
114-
Vector,
115-
Bufferlist,
116-
SparseBufferlist> Buffer;
109+
typedef std::variant<std::monostate,
110+
Linear,
111+
Vector,
112+
Bufferlist,
113+
SparseBufferlist> Buffer;
117114
struct SetImageExtentsVisitor;
118115
struct AssembleResultVisitor;
119116

0 commit comments

Comments
 (0)