Skip to content

Commit fd0a655

Browse files
[core] Activated C++17 standard (#2444)
Co-authored-by: Kerstin Keller <[email protected]>
1 parent cf2c42c commit fd0a655

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

ecal/core/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,7 +726,7 @@ target_link_libraries(ecal_core_private
726726
ecal_core_serialization $<TARGET_OBJECTS:ecal_core_serialization>
727727
)
728728

729-
target_compile_features(ecal_core_private PUBLIC cxx_std_14)
729+
target_compile_features(ecal_core_private PUBLIC cxx_std_17)
730730

731731
set_property(TARGET ecal_core_private PROPERTY FOLDER core)
732732
set_property(TARGET ecal_core_private PROPERTY POSITION_INDEPENDENT_CODE ON)
@@ -792,6 +792,9 @@ set_target_properties(core
792792
VISIBILITY_INLINES_HIDDEN ON
793793
)
794794

795+
target_compile_features(core INTERFACE cxx_std_14)
796+
target_compile_features(core PRIVATE cxx_std_17)
797+
795798
set_property(TARGET core PROPERTY FOLDER core)
796799
endmacro()
797800

ecal/core/src/util/frequency_calculator.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <atomic>
2828
#include <chrono>
2929
#include <memory>
30+
#include <optional>
3031
#include <numeric>
3132

3233
namespace eCAL
@@ -99,11 +100,11 @@ namespace eCAL
99100
{
100101
if (!calculator)
101102
{
102-
calculator = std::make_unique<FrequencyCalculator<T>>(now);
103+
calculator = FrequencyCalculator<T>(now);
103104
}
104105
else
105106
{
106-
calculator->addTick(now);
107+
calculator.value().addTick(now);
107108
}
108109
last_tick_time = now;
109110
received_tick_since_get_frequency_called = true;
@@ -137,7 +138,7 @@ namespace eCAL
137138
time_point timeout_time = last_tick_time + std::chrono::duration_cast<std::chrono::nanoseconds>(expected_time_in_seconds_between_last_and_next_tick * reset_factor);
138139
if (now > timeout_time)
139140
{
140-
calculator.reset();
141+
calculator = std::nullopt;
141142
return 0.0;
142143
}
143144

@@ -148,7 +149,7 @@ namespace eCAL
148149
float reset_factor;
149150
time_point last_tick_time;
150151
bool received_tick_since_get_frequency_called = false;
151-
std::unique_ptr<FrequencyCalculator<T>> calculator;
152+
std::optional<FrequencyCalculator<T>> calculator;
152153
};
153154
}
154155

0 commit comments

Comments
 (0)