Skip to content

Commit f835ec0

Browse files
authored
Merge pull request ceph#62336 from tchaikov/librbd-std-variant
librbd: migrate from boost::variant to std::variant Reviewed-by: Ilya Dryomov <[email protected]>
2 parents 408021d + 017f333 commit f835ec0

13 files changed

+28
-29
lines changed

src/librbd/internal.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@
5959
#include "journal/Journaler.h"
6060

6161
#include <boost/scope_exit.hpp>
62-
#include <boost/variant.hpp>
6362
#include "include/ceph_assert.h"
6463

6564
#include <shared_mutex> // for std::shared_lock
65+
#include <variant>
6666

6767
#define dout_subsys ceph_subsys_rbd
6868
#undef dout_prefix
@@ -275,7 +275,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
275275
return io_ctx.tmap_update(RBD_DIRECTORY, cmdbl);
276276
}
277277

278-
typedef boost::variant<std::string,uint64_t> image_option_value_t;
278+
typedef std::variant<std::string, uint64_t> image_option_value_t;
279279
typedef std::map<int,image_option_value_t> image_options_t;
280280
typedef std::shared_ptr<image_options_t> image_options_ref;
281281

@@ -433,7 +433,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
433433
return -ENOENT;
434434
}
435435

436-
*optval = boost::get<std::string>(j->second);
436+
*optval = std::get<std::string>(j->second);
437437
return 0;
438438
}
439439

@@ -454,7 +454,7 @@ int validate_pool(IoCtx &io_ctx, CephContext *cct) {
454454
return -ENOENT;
455455
}
456456

457-
*optval = boost::get<uint64_t>(j->second);
457+
*optval = std::get<uint64_t>(j->second);
458458
return 0;
459459
}
460460

src/librbd/io/ImageDispatchSpec.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
#include "librbd/io/AioCompletion.h"
1212
#include "librbd/io/Types.h"
1313
#include "librbd/io/ReadResult.h"
14-
#include <boost/variant/variant.hpp>
1514
#include <atomic>
15+
#include <variant>
1616

1717
namespace librbd {
1818

@@ -99,13 +99,13 @@ class ImageDispatchSpec {
9999
}
100100
};
101101

102-
typedef boost::variant<Read,
103-
Discard,
104-
Write,
105-
WriteSame,
106-
CompareAndWrite,
107-
Flush,
108-
ListSnaps> Request;
102+
typedef std::variant<Read,
103+
Discard,
104+
Write,
105+
WriteSame,
106+
CompareAndWrite,
107+
Flush,
108+
ListSnaps> Request;
109109

110110
C_Dispatcher dispatcher_ctx;
111111

src/librbd/io/ImageDispatcher.cc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include "librbd/io/RefreshImageDispatch.h"
1515
#include "librbd/io/Utils.h"
1616
#include "librbd/io/WriteBlockImageDispatch.h"
17-
#include <boost/variant.hpp>
1817

1918
#include <shared_mutex> // for std::shared_lock
2019

@@ -280,15 +279,15 @@ bool ImageDispatcher<I>::send_dispatch(
280279
}
281280
}
282281

283-
return boost::apply_visitor(
282+
return std::visit(
284283
SendVisitor{image_dispatch, image_dispatch_spec},
285284
image_dispatch_spec->request);
286285
}
287286

288287
template <typename I>
289288
bool ImageDispatcher<I>::preprocess(
290289
ImageDispatchSpec* image_dispatch_spec) {
291-
return boost::apply_visitor(
290+
return std::visit(
292291
PreprocessVisitor{this, image_dispatch_spec},
293292
image_dispatch_spec->request);
294293
}

src/test/librbd/crypto/luks/test_mock_FlattenRequest.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ struct TestMockCryptoLuksFlattenRequest : public TestMockFixture {
9696
EXPECT_CALL(*mock_image_ctx->io_image_dispatcher, send(_))
9797
.WillOnce(Invoke([this, offset,
9898
length](io::ImageDispatchSpec* spec) {
99-
auto* read = boost::get<io::ImageDispatchSpec::Read>(
99+
auto* read = std::get_if<io::ImageDispatchSpec::Read>(
100100
&spec->request);
101101
ASSERT_TRUE(read != nullptr);
102102

@@ -122,7 +122,7 @@ struct TestMockCryptoLuksFlattenRequest : public TestMockFixture {
122122
void expect_image_write() {
123123
EXPECT_CALL(*mock_image_ctx->io_image_dispatcher, send(_))
124124
.WillOnce(Invoke([this](io::ImageDispatchSpec* spec) {
125-
auto* write = boost::get<io::ImageDispatchSpec::Write>(
125+
auto* write = std::get_if<io::ImageDispatchSpec::Write>(
126126
&spec->request);
127127
ASSERT_TRUE(write != nullptr);
128128

@@ -145,7 +145,7 @@ struct TestMockCryptoLuksFlattenRequest : public TestMockFixture {
145145
void expect_image_flush(int r) {
146146
EXPECT_CALL(*mock_image_ctx->io_image_dispatcher, send(_)).WillOnce(
147147
Invoke([r](io::ImageDispatchSpec* spec) {
148-
ASSERT_TRUE(boost::get<io::ImageDispatchSpec::Flush>(
148+
ASSERT_TRUE(std::get_if<io::ImageDispatchSpec::Flush>(
149149
&spec->request) != nullptr);
150150
spec->dispatch_result = io::DISPATCH_RESULT_COMPLETE;
151151
spec->aio_comp->set_request_count(1);

src/test/librbd/crypto/luks/test_mock_FormatRequest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ struct TestMockCryptoLuksFormatRequest : public TestMockFixture {
6666
void expect_image_write() {
6767
EXPECT_CALL(*mock_image_ctx->io_image_dispatcher, send(_))
6868
.WillOnce(Invoke([this](io::ImageDispatchSpec* spec) {
69-
auto* write = boost::get<io::ImageDispatchSpec::Write>(
69+
auto* write = std::get_if<io::ImageDispatchSpec::Write>(
7070
&spec->request);
7171
ASSERT_TRUE(write != nullptr);
7272

src/test/librbd/crypto/luks/test_mock_LoadRequest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ struct TestMockCryptoLuksLoadRequest : public TestMockFixture {
8181
EXPECT_CALL(*mock_image_ctx->io_image_dispatcher, send(_))
8282
.WillOnce(Invoke([this, offset,
8383
length](io::ImageDispatchSpec* spec) {
84-
auto* read = boost::get<io::ImageDispatchSpec::Read>(
84+
auto* read = std::get_if<io::ImageDispatchSpec::Read>(
8585
&spec->request);
8686
ASSERT_TRUE(read != nullptr);
8787

src/test/librbd/crypto/test_mock_FormatRequest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ struct TestMockCryptoFormatRequest : public TestMockFixture {
135135
void expect_image_flush(int r) {
136136
EXPECT_CALL(*mock_image_ctx->io_image_dispatcher, send(_)).WillOnce(
137137
Invoke([r](io::ImageDispatchSpec* spec) {
138-
ASSERT_TRUE(boost::get<io::ImageDispatchSpec::Flush>(
138+
ASSERT_TRUE(std::get_if<io::ImageDispatchSpec::Flush>(
139139
&spec->request) != nullptr);
140140
spec->dispatch_result = io::DISPATCH_RESULT_COMPLETE;
141141
spec->aio_comp->set_request_count(1);

src/test/librbd/crypto/test_mock_LoadRequest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ struct TestMockCryptoLoadRequest : public TestMockFixture {
119119
void expect_image_flush(int r = 0) {
120120
EXPECT_CALL(*mock_image_ctx->io_image_dispatcher, send(_)).WillOnce(
121121
Invoke([r](io::ImageDispatchSpec* spec) {
122-
ASSERT_TRUE(boost::get<io::ImageDispatchSpec::Flush>(
122+
ASSERT_TRUE(std::get_if<io::ImageDispatchSpec::Flush>(
123123
&spec->request) != nullptr);
124124
spec->dispatch_result = io::DISPATCH_RESULT_COMPLETE;
125125
spec->aio_comp->set_request_count(1);

src/test/librbd/deep_copy/test_mock_ObjectCopyRequest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@ void scribble(librbd::ImageCtx *image_ctx, int num_ops, size_t max_size,
119119

120120

121121
MATCHER(IsListSnaps, "") {
122-
auto req = boost::get<io::ImageDispatchSpec::ListSnaps>(&arg->request);
122+
auto req = std::get_if<io::ImageDispatchSpec::ListSnaps>(&arg->request);
123123
return (req != nullptr);
124124
}
125125

126126
MATCHER_P2(IsRead, snap_id, image_interval, "") {
127-
auto req = boost::get<io::ImageDispatchSpec::Read>(&arg->request);
127+
auto req = std::get_if<io::ImageDispatchSpec::Read>(&arg->request);
128128
if (req == nullptr ||
129129
arg->io_context->get_read_snap() != snap_id) {
130130
return false;

src/test/librbd/exclusive_lock/test_mock_PreReleaseRequest.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class TestMockExclusiveLockPreReleaseRequest : public TestMockFixture {
168168
void expect_flush_io(MockTestImageCtx &mock_image_ctx, int r) {
169169
EXPECT_CALL(*mock_image_ctx.io_image_dispatcher, send(_))
170170
.WillOnce(Invoke([&mock_image_ctx, r](io::ImageDispatchSpec* spec) {
171-
ASSERT_TRUE(boost::get<io::ImageDispatchSpec::Flush>(
171+
ASSERT_TRUE(std::get_if<io::ImageDispatchSpec::Flush>(
172172
&spec->request) != nullptr);
173173
spec->dispatch_result = io::DISPATCH_RESULT_COMPLETE;
174174
auto aio_comp = spec->aio_comp;

0 commit comments

Comments
 (0)