Skip to content

Commit 5354d90

Browse files
committed
Apply clang-format to example files.
1 parent 7719192 commit 5354d90

1 file changed

Lines changed: 13 additions & 16 deletions

File tree

examples/example_variant2.cpp

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include <string>
33
#include <variant>
44

5-
#include <dice/template-library/variant2.hpp>
65
#include <dice/template-library/overloaded.hpp>
6+
#include <dice/template-library/variant2.hpp>
77

88
namespace dtl = dice::template_library;
99
using namespace std::literals;
@@ -14,39 +14,36 @@ int main() {
1414
dtl::variant2<int, float> v;
1515
dtl::variant2<int, float> w;
1616

17-
v = 42; // v contains int
17+
v = 42;// v contains int
1818
int i = dtl::get<int>(v);
19-
assert(42 == i); // succeeds
19+
assert(42 == i);// succeeds
2020
w = dtl::get<int>(v);
21-
w = dtl::get<0>(v); // same effect as the previous line
22-
w = v; // same effect as the previous line
21+
w = dtl::get<0>(v);// same effect as the previous line
22+
w = v; // same effect as the previous line
2323

2424
// dtl::get<double>(v); // error: no double in [int, float]
2525
// dtl::get<3>(v); // error: valid index values are 0 and 1
2626

2727
try {
28-
(void) dtl::get<float>(w); // w contains int, not float: will throw
29-
}
30-
catch (dtl::bad_variant_access const &ex) {
28+
(void) dtl::get<float>(w);// w contains int, not float: will throw
29+
} catch (dtl::bad_variant_access const &ex) {
3130
assert(ex.what() == "bad variant access"s);
3231
}
3332

3433
dtl::variant<std::string> x("abc");
3534
// converting constructors work when unambiguous
36-
x = "def"; // converting assignment also works when unambiguous
35+
x = "def";// converting assignment also works when unambiguous
3736

38-
dtl::variant<std::string, void const*> y("abc");
37+
dtl::variant<std::string, void const *> y("abc");
3938
// casts to void const* when passed a char const*
40-
assert(dtl::holds_alternative<void const*>(y)); // succeeds
39+
assert(dtl::holds_alternative<void const *>(y));// succeeds
4140
y = "xyz"s;
42-
assert(dtl::holds_alternative<std::string>(y)); // succeeds
41+
assert(dtl::holds_alternative<std::string>(y));// succeeds
4342

4443
auto visitor = dtl::overloaded{
45-
[](int x) { return x; },
46-
[](double d) { return static_cast<int>(d); }
47-
};
44+
[](int x) { return x; },
45+
[](double d) { return static_cast<int>(d); }};
4846

4947
auto z = dtl::visit(visitor, v);
5048
assert(z == 42);
51-
5249
}

0 commit comments

Comments
 (0)