Skip to content

Commit 3f017f3

Browse files
committed
fable: Implement clang-tidy suggestions
1 parent 984fda4 commit 3f017f3

File tree

4 files changed

+7
-10
lines changed

4 files changed

+7
-10
lines changed

fable/examples/contacts/src/main.cpp

+6-7
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,13 @@
6363
#include <iostream> // for std::{cout, cerr}
6464
#include <string> // for std::string<>
6565
#include <vector> // for std::vector<>
66+
#include <optional> // for std::optional<>
6667

6768
#include <fmt/format.h> // for fmt::format
6869
#include <CLI/CLI.hpp> // for CLI::App
69-
#include <boost/optional.hpp> // for boost::optional<>
7070

7171
#include <fable/confable.hpp> // for fable::{Confable, CONFABLE_SCHEMA}
7272
#include <fable/schema.hpp> // for fable::{Schema, String}
73-
#include <fable/schema/boost_optional.hpp> // for fable::{Optional, make_schema}
7473
#include <fable/utility.hpp> // for fable::{read_conf}
7574

7675
// All structs that are used directly with fable for serialization and
@@ -170,16 +169,16 @@ struct Contact : public fable::Confable {
170169
std::string firstName;
171170
std::string lastName;
172171
bool isAlive{false};
173-
boost::optional<uint8_t> age{0};
172+
std::optional<uint8_t> age{0};
174173

175-
boost::optional<Address> address;
174+
std::optional<Address> address;
176175
std::vector<PhoneNumber> phoneNumbers;
177176
std::vector<std::string> children;
178-
boost::optional<std::string> spouse;
177+
std::optional<std::string> spouse;
179178

180179
Contact() = default;
181180
Contact(
182-
std::string first, std::string last, bool alive, boost::optional<uint8_t> age) noexcept
181+
std::string first, std::string last, bool alive, std::optional<uint8_t> age) noexcept
183182
: firstName(std::move(first)), lastName(std::move(last)), isAlive(alive), age(age) {}
184183

185184
Contact with_address(Address&& addr) && {
@@ -222,7 +221,7 @@ int main(int argc, char** argv) {
222221
Contact("John", "Smith", true, 42)
223222
.with_address({"Generate Road 12", "Nowhere", "NA", "00000"})
224223
.with_phone({PhoneType::Home, "+1 650 0000 000"}),
225-
Contact("Jane", "Doe", false, boost::none),
224+
Contact("Jane", "Doe", false, std::nullopt),
226225
};
227226

228227
// If we don't have a Confable, we can create a Schema on the fly and pass

fable/examples/simple_config/src/main.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ int main(int argc, char **argv) {
8484
try {
8585
std::cout << fmt::format("Loading config from {}", filename) << std::endl;
8686
config.from_conf(fable::read_conf(filename));
87-
} catch (fable::Error e) {
87+
} catch (fable::Error& e) {
8888
std::cerr << fmt::format("\n\n{0:=^{1}}\n", " JSON-Validation ", header_width) << std::endl;
8989
std::cerr << fmt::format("Error: {}", e.what()) << std::endl;
9090
return 1;

fable/include/fable/conf.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@
5757
#include <vector> // for vector<>
5858

5959
#include <fmt/format.h> // for fmt::format
60-
6160
#include <fable/fable_fwd.hpp> // for ConfError
6261
#include <fable/json.hpp> // for Json
6362

fable/include/fable/schema/factory.hpp

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#pragma once
2424

2525
#include <functional> // for function<>
26-
#include <limits> // for numeric_limits<>
2726
#include <map> // for map<>
2827
#include <memory> // for shared_ptr<>
2928
#include <string> // for string

0 commit comments

Comments
 (0)