Skip to content

Commit

Permalink
fable: Implement clang-tidy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
cassava committed Jul 12, 2024
1 parent 984fda4 commit 3f017f3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 10 deletions.
13 changes: 6 additions & 7 deletions fable/examples/contacts/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,13 @@
#include <iostream> // for std::{cout, cerr}
#include <string> // for std::string<>
#include <vector> // for std::vector<>
#include <optional> // for std::optional<>

#include <fmt/format.h> // for fmt::format
#include <CLI/CLI.hpp> // for CLI::App
#include <boost/optional.hpp> // for boost::optional<>

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

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

boost::optional<Address> address;
std::optional<Address> address;
std::vector<PhoneNumber> phoneNumbers;
std::vector<std::string> children;
boost::optional<std::string> spouse;
std::optional<std::string> spouse;

Contact() = default;
Contact(
std::string first, std::string last, bool alive, boost::optional<uint8_t> age) noexcept
std::string first, std::string last, bool alive, std::optional<uint8_t> age) noexcept
: firstName(std::move(first)), lastName(std::move(last)), isAlive(alive), age(age) {}

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

// If we don't have a Confable, we can create a Schema on the fly and pass
Expand Down
2 changes: 1 addition & 1 deletion fable/examples/simple_config/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ int main(int argc, char **argv) {
try {
std::cout << fmt::format("Loading config from {}", filename) << std::endl;
config.from_conf(fable::read_conf(filename));
} catch (fable::Error e) {
} catch (fable::Error& e) {
std::cerr << fmt::format("\n\n{0:=^{1}}\n", " JSON-Validation ", header_width) << std::endl;
std::cerr << fmt::format("Error: {}", e.what()) << std::endl;
return 1;
Expand Down
1 change: 0 additions & 1 deletion fable/include/fable/conf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
#include <vector> // for vector<>

#include <fmt/format.h> // for fmt::format

#include <fable/fable_fwd.hpp> // for ConfError
#include <fable/json.hpp> // for Json

Expand Down
1 change: 0 additions & 1 deletion fable/include/fable/schema/factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#pragma once

#include <functional> // for function<>
#include <limits> // for numeric_limits<>
#include <map> // for map<>
#include <memory> // for shared_ptr<>
#include <string> // for string
Expand Down

0 comments on commit 3f017f3

Please sign in to comment.