Skip to content

Commit

Permalink
Use https://github.com/martinmoene/optional-lite instead of std::opti…
Browse files Browse the repository at this point in the history
…onal

Since the only reason we used C++17 was to get std::optional, we downgrade
to C++11 in CMakeLists.

This commit imports version 3.2.0 of optional-lite.
  • Loading branch information
svedi committed Oct 25, 2019
1 parent ccad315 commit 73f1840
Show file tree
Hide file tree
Showing 4 changed files with 1,726 additions and 6 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ add_library (cryptolens STATIC ${SRC})
target_link_libraries (cryptolens ${LIBS})
target_include_directories (cryptolens PRIVATE "${cryptolens_SOURCE_DIR}/include/cryptolens")
target_include_directories (cryptolens PUBLIC "${cryptolens_SOURCE_DIR}/include")
set_property (TARGET cryptolens PROPERTY CXX_STANDARD 17)
set_property (TARGET cryptolens PROPERTY CXX_STANDARD 11)
set_property (TARGET cryptolens PROPERTY CXX_STANDARD_REQURED ON)

if (${CRYPTOLENS_BUILD_TESTS})
Expand Down
10 changes: 5 additions & 5 deletions examples/unix/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ add_subdirectory ("../../.." "cryptolens-cpp")

add_executable(example_activate ../example_activate.cpp)
target_link_libraries(example_activate cryptolens)
set_property(TARGET example_activate PROPERTY CXX_STANDARD 17)
set_property(TARGET example_activate PROPERTY CXX_STANDARD 11)
set_property(TARGET example_activate PROPERTY CXX_STANDARD_REQURED ON)

add_executable(example_create_trial_key ../example_create_trial_key.cpp)
target_link_libraries(example_create_trial_key cryptolens)
set_property(TARGET example_create_trial_key PROPERTY CXX_STANDARD 17)
set_property(TARGET example_create_trial_key PROPERTY CXX_STANDARD 11)
set_property(TARGET example_create_trial_key PROPERTY CXX_STANDARD_REQURED ON)

add_executable(example_external ../example_external.cpp)
target_link_libraries(example_external cryptolens)
set_property(TARGET example_external PROPERTY CXX_STANDARD 17)
set_property(TARGET example_external PROPERTY CXX_STANDARD 11)
set_property(TARGET example_external PROPERTY CXX_STANDARD_REQURED ON)

add_executable(example_floating ../example_floating.cpp)
target_link_libraries(example_floating cryptolens)
set_property(TARGET example_floating PROPERTY CXX_STANDARD 17)
set_property(TARGET example_floating PROPERTY CXX_STANDARD 11)
set_property(TARGET example_floating PROPERTY CXX_STANDARD_REQURED ON)

add_executable(example_offline ../example_offline.cpp)
target_link_libraries(example_offline cryptolens)
set_property(TARGET example_offline PROPERTY CXX_STANDARD 17)
set_property(TARGET example_offline PROPERTY CXX_STANDARD 11)
set_property(TARGET example_offline PROPERTY CXX_STANDARD_REQURED ON)
22 changes: 22 additions & 0 deletions include/cryptolens/imports/std/optional
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
#pragma once

#if __cplusplus < 201703L

#include "../../../../third_party/optional-lite/optional.hpp"

namespace cryptolens_io {

namespace v20190401 {

template<typename T>
using optional = ::nonstd::optional<T>;

using ::nonstd::make_optional;
using ::nonstd::nullopt;

} // namespace v20190401

} // namespace cryptolens_io

#else

#include <optional>

namespace cryptolens_io {
Expand All @@ -16,6 +36,8 @@ using std::nullopt;

} // namespace cryptolens_io

#endif

namespace cryptolens_io {

namespace latest {
Expand Down
Loading

0 comments on commit 73f1840

Please sign in to comment.