Skip to content

Commit

Permalink
AVRO-4096: [C++] Replace boost::optional with std::optional (#3254)
Browse files Browse the repository at this point in the history
  • Loading branch information
wgtmac authored Dec 6, 2024
1 parent 4f61326 commit 77540f6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
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

0 comments on commit 77540f6

Please sign in to comment.