This is an automated email from the ASF dual-hosted git repository.

fokko pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/avro.git


The following commit(s) were added to refs/heads/main by this push:
     new 77540f6f6 AVRO-4096: [C++] Replace `boost::optional` with 
`std::optional` (#3254)
77540f6f6 is described below

commit 77540f6f62bb09b3bc9c991c7a6d295c9d273878
Author: Gang Wu <[email protected]>
AuthorDate: Fri Dec 6 14:46:39 2024 +0800

    AVRO-4096: [C++] Replace `boost::optional` with `std::optional` (#3254)
---
 lang/c++/impl/CustomAttributes.cc         | 4 ++--
 lang/c++/include/avro/CustomAttributes.hh | 4 ++--
 lang/c++/test/unittest.cc                 | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lang/c++/impl/CustomAttributes.cc 
b/lang/c++/impl/CustomAttributes.cc
index 13c56a5e9..f31b557ae 100644
--- a/lang/c++/impl/CustomAttributes.cc
+++ b/lang/c++/impl/CustomAttributes.cc
@@ -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()) {
diff --git a/lang/c++/include/avro/CustomAttributes.hh 
b/lang/c++/include/avro/CustomAttributes.hh
index b4cc6fbba..4b76b45a5 100644
--- a/lang/c++/include/avro/CustomAttributes.hh
+++ b/lang/c++/include/avro/CustomAttributes.hh
@@ -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 {
@@ -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);
diff --git a/lang/c++/test/unittest.cc b/lang/c++/test/unittest.cc
index 3558a0e2f..b0cb44c5b 100644
--- a/lang/c++/test/unittest.cc
+++ b/lang/c++/test/unittest.cc
@@ -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() {

Reply via email to