Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AVRO-4096: [C++] Replace boost::optional with std::optional #3254

Merged
merged 1 commit into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lang/c++/impl/CustomAttributes.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

namespace avro {

boost::optional<std::string> CustomAttributes::getAttribute(const std::string &name) const {
boost::optional<std::string> result;
std::optional<std::string> CustomAttributes::getAttribute(const std::string &name) const {
std::optional<std::string> result;
std::map<std::string, std::string>::const_iterator iter =
attributes_.find(name);
if (iter == attributes_.end()) {
Expand Down
4 changes: 2 additions & 2 deletions lang/c++/include/avro/CustomAttributes.hh
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
#define avro_CustomAttributes_hh__

#include "Config.hh"
#include <boost/optional.hpp>
#include <iostream>
#include <map>
#include <optional>
#include <string>

namespace avro {
Expand All @@ -34,7 +34,7 @@ class AVRO_DECL CustomAttributes {
public:
// Retrieves the custom attribute json entity for that attributeName, returns an
// null if the attribute doesn't exist.
boost::optional<std::string> getAttribute(const std::string &name) const;
std::optional<std::string> getAttribute(const std::string &name) const;

// Adds a custom attribute. If the attribute already exists, throw an exception.
void addAttribute(const std::string &name, const std::string &value);
Expand Down
2 changes: 1 addition & 1 deletion lang/c++/test/unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ struct TestSchema {
cf.addAttribute("field1", std::string("1"));

BOOST_CHECK_EQUAL(std::string("1"), *cf.getAttribute("field1"));
BOOST_CHECK_EQUAL(false, cf.getAttribute("not_existing").is_initialized());
BOOST_CHECK_EQUAL(false, cf.getAttribute("not_existing").has_value());
}

void test() {
Expand Down
Loading