Skip to content

Commit f9719c0

Browse files
committed
Use std::optional if available.
Currently, SDK requires C++11 minimum. So, boost::optional type is used for optional values. For C++17 and above more convenient is to use std::optional instead. The task NLAM-23 is about making this type configurable. This commit makes the boost::optional default even for C++17 builds. The std::optional usage shall be switched on explicitly using OLP_SDK_USE_STD_OPTIONAL=ON flag. Relates-To: NLAM-23 Signed-off-by: sopov <[email protected]>
1 parent ccdd33b commit f9719c0

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ endif()
3737
option(OLP_SDK_ENABLE_TESTING "Flag to enable/disable building unit and integration tests" ON)
3838
option(OLP_SDK_BUILD_DOC "Build SDK documentation" OFF)
3939
option(OLP_SDK_NO_EXCEPTION "Disable exception handling" OFF)
40-
option(OLP_SDK_FORCE_BOOST_OPTIONAL "Use boost::optional instead of std::optional with C++17 and above" OFF)
40+
option(OLP_SDK_USE_STD_OPTIONAL "Use std::optional instead of boost::optional with C++17 and above" OFF)
4141
option(OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL "The boost::throw_exception() is defined externally" OFF)
4242
option(OLP_SDK_BUILD_EXTERNAL_DEPS "Download and build external dependencies" ON)
4343
option(OLP_SDK_BUILD_EXAMPLES "Enable examples targets" OFF)

docs/get-started.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ cmake --build . --target docs
130130
| `OLP_SDK_ENABLE_TESTING` | Defaults to `ON`. If enabled, unit tests are built for each library. |
131131
| `OLP_SDK_BUILD_EXTERNAL_DEPS` | Defaults to `ON`. If enabled, CMake downloads and compiles dependencies. |
132132
| `OLP_SDK_NO_EXCEPTION` | Defaults to `OFF`. If enabled, all libraries are built without exceptions. |
133-
| `OLP_SDK_FORCE_BOOST_OPTIONAL` | Defaults to `OFF`. If enabled, all libraries are built with boost::optional type even when std::optional is available. |
133+
| `OLP_SDK_USE_STD_OPTIONAL` | Defaults to `OFF`. If enabled, all libraries are built with std::optional type if it's available. |
134134
| `OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL` | Defaults to `OFF`. When `OLP_SDK_NO_EXCEPTION` is `ON`, `boost` requires `boost::throw_exception()` to be defined. If enabled, the external definition of `boost::throw_exception()` is used. Otherwise, the library uses own definition. |
135135
| `OLP_SDK_MSVC_PARALLEL_BUILD_ENABLE` (Windows Only) | Defaults to `ON`. If enabled, the `/MP` compilation flag is added to build the Data SDK using multiple cores. |
136136
| `OLP_SDK_DISABLE_DEBUG_LOGGING`| Defaults to `OFF`. If enabled, the debug and trace level log messages are not printed. |
@@ -176,4 +176,4 @@ HERE Data SDK for C++ contains several example programs that demonstrate some of
176176
- [Read example](dataservice-read-catalog-example.md) – demonstrates how to get catalog and partition metadata, as well as partition data.
177177
- [Read example for a stream layer](dataservice-read-from-stream-layer-example.md) – demonstrates how to get data from a stream layer.
178178
- [Cache example](dataservice-cache-example.md) – demonstrates how to get partition data and work with a mutable and protected cache.
179-
- [Write example](dataservice-write-example.md) – demonstrates how to publish data to the HERE platform.
179+
- [Write example](dataservice-write-example.md) – demonstrates how to publish data to the HERE platform.

olp-cpp-sdk-core/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,9 +440,9 @@ if (OLP_SDK_NO_EXCEPTION AND NOT OLP_SDK_BOOST_THROW_EXCEPTION_EXTERNAL)
440440
PRIVATE OLP_SDK_BOOST_THROW_EXCEPTION=1)
441441
endif()
442442

443-
if (OLP_SDK_FORCE_BOOST_OPTIONAL)
443+
if (OLP_SDK_USE_STD_OPTIONAL)
444444
target_compile_definitions(${PROJECT_NAME}
445-
PUBLIC OLP_CPP_SDK_USE_BOOST_OPTIONAL)
445+
PUBLIC OLP_CPP_SDK_USE_STD_OPTIONAL)
446446
endif()
447447

448448
target_include_directories(${PROJECT_NAME} PUBLIC

olp-cpp-sdk-core/include/olp/core/porting/optional.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
#pragma once
2121

22-
#if (__cplusplus >= 201703L) && !defined(OLP_CPP_SDK_USE_BOOST_OPTIONAL)
22+
#if (__cplusplus >= 201703L) && defined(OLP_CPP_SDK_USE_STD_OPTIONAL)
2323
#include <optional>
2424

2525
namespace olp {

0 commit comments

Comments
 (0)