Skip to content

Commit c8ec151

Browse files
Bring back C++17 minimal requirement. (#475)
1 parent 1d76a23 commit c8ec151

File tree

10 files changed

+42
-33
lines changed

10 files changed

+42
-33
lines changed

cmake/ftxui_set_options.cmake

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ endif()
99
function(ftxui_set_options library)
1010
set_target_properties(${library} PROPERTIES
1111
VERSION ${PROJECT_VERSION}
12-
CXX_STANDARD 20
1312
OUTPUT_NAME "ftxui-${library}"
1413
)
1514

cmake/ftxui_test.cmake

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ target_include_directories(tests
7171
PRIVATE src
7272
)
7373
ftxui_set_options(tests)
74+
target_compile_features(tests PUBLIC cxx_std_20)
7475

7576
include(GoogleTest)
7677
gtest_discover_tests(tests

codecov.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
codecov:
22
require_ci_to_pass: no
33
notify:
4-
after_n_builds: 3
4+
after_n_builds: 4
55
wait_for_ci: yes
66

77
coverage:

examples/component/slider_direction.cpp

+17-5
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
#include <array> // for array
2-
#include <cmath> // for sin
3-
#include <ftxui/component/component_base.hpp> // for ComponentBase
4-
#include <ftxui/dom/elements.hpp> // for size, GaugeDirection, GaugeDirection::Up, GREATER_THAN, HEIGHT
5-
#include <memory> // for shared_ptr, __shared_ptr_access
1+
#include <array> // for array
2+
#include <cmath> // for sin
3+
#include <ftxui/component/component_base.hpp> // for ComponentBase
4+
#include <ftxui/component/component_options.hpp> // for SliderOption
5+
#include <ftxui/dom/elements.hpp> // for size, GREATER_THAN, GaugeDirection, GaugeDirection::Up, HEIGHT
6+
#include <ftxui/util/ref.hpp> // for ConstRef, Ref
7+
#include <memory> // for shared_ptr, __shared_ptr_access
68

79
#include "ftxui/component/captured_mouse.hpp" // for ftxui
810
#include "ftxui/component/component.hpp" // for Horizontal, Slider, operator|=
@@ -19,12 +21,22 @@ int main(int argc, const char* argv[]) {
1921

2022
auto layout_horizontal = Container::Horizontal({});
2123
for (int i = 0; i < values.size(); ++i) {
24+
// In C++17:
25+
SliderOption<int> option;
26+
option.value = &values[i];
27+
option.max = 100;
28+
option.increment = 5;
29+
option.direction = GaugeDirection::Up;
30+
layout_horizontal->Add(Slider<int>(option));
31+
32+
/* In C++20:
2233
layout_horizontal->Add(Slider<int>({
2334
.value = &values[i],
2435
.max = 100,
2536
.increment = 5,
2637
.direction = GaugeDirection::Up,
2738
}));
39+
*/
2840
}
2941

3042
layout_horizontal |= size(HEIGHT, GREATER_THAN, 20);

include/ftxui/screen/screen.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#define FTXUI_SCREEN_SCREEN_HPP
33

44
#include <memory>
5-
#include <string> // for allocator, string, basic_string
5+
#include <string> // for string, allocator, basic_string
66
#include <vector> // for vector
77

88
#include "ftxui/screen/box.hpp" // for Box

src/ftxui/component/animation.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include <cmath> // IWYU pragma: keep
2-
#include <compare> // for operator<=, operator>=, partial_ordering
32
#include <ratio> // for ratio
43
#include <utility> // for move
54

src/ftxui/component/radiobox.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ class RadioboxBase : public ComponentBase {
2626
RadioboxBase(ConstStringListRef entries,
2727
int* selected,
2828
Ref<RadioboxOption> option)
29-
: entries_(entries), selected_(selected), option_(std::move(option)) {
30-
}
29+
: entries_(entries), selected_(selected), option_(std::move(option)) {}
3130

3231
private:
3332
Element Render() override {

src/ftxui/component/screen_interactive.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
#include <algorithm> // for min
1+
#include <algorithm> // for copy, max, min
22
#include <array> // for array
3-
#include <chrono> // for operator-, milliseconds, duration, operator<=>, time_point, common_type<>::type
4-
#include <compare> // for operator>=, strong_ordering
3+
#include <chrono> // for operator-, milliseconds, duration, operator>=, time_point, common_type<>::type
54
#include <csignal> // for signal, raise, SIGTSTP, SIGABRT, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM, SIGWINCH
65
#include <cstdio> // for fileno, size_t, stdin
76
#include <ftxui/component/task.hpp> // for Task, Closure, AnimationTask

src/ftxui/component/slider.cpp

+18-18
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,12 @@ Component Slider(ConstStringRef label,
266266
ConstRef<int> min,
267267
ConstRef<int> max,
268268
ConstRef<int> increment) {
269-
auto slider = Make<SliderBase<int>>(SliderOption<int>({
270-
.value = value,
271-
.min = min,
272-
.max = max,
273-
.increment = increment,
274-
}));
269+
SliderOption<int> option;
270+
option.value = value;
271+
option.min = min;
272+
option.max = max;
273+
option.increment = increment;
274+
auto slider = Make<SliderBase<int>>(option);
275275
return Make<SliderWithLabel>(label, slider);
276276
}
277277

@@ -280,25 +280,25 @@ Component Slider(ConstStringRef label,
280280
ConstRef<float> min,
281281
ConstRef<float> max,
282282
ConstRef<float> increment) {
283-
auto slider = Make<SliderBase<float>>(SliderOption<float>({
284-
.value = value,
285-
.min = min,
286-
.max = max,
287-
.increment = increment,
288-
}));
283+
SliderOption<float> option;
284+
option.value = value;
285+
option.min = min;
286+
option.max = max;
287+
option.increment = increment;
288+
auto slider = Make<SliderBase<float>>(option);
289289
return Make<SliderWithLabel>(label, slider);
290290
}
291291
Component Slider(ConstStringRef label,
292292
Ref<long> value,
293293
ConstRef<long> min,
294294
ConstRef<long> max,
295295
ConstRef<long> increment) {
296-
auto slider = Make<SliderBase<long>>(SliderOption<long>({
297-
.value = value,
298-
.min = min,
299-
.max = max,
300-
.increment = increment,
301-
}));
296+
SliderOption<long> option;
297+
option.value = value;
298+
option.min = min;
299+
option.max = max;
300+
option.increment = increment;
301+
auto slider = Make<SliderBase<long>>(option);
302302
return Make<SliderWithLabel>(label, slider);
303303
}
304304

src/ftxui/screen/color.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ Color Color::RGB(uint8_t red, uint8_t green, uint8_t blue) {
145145
// static
146146
Color Color::HSV(uint8_t h, uint8_t s, uint8_t v) {
147147
if (s == 0) {
148-
return {0,0,0};
148+
return {0, 0, 0};
149149
}
150150

151151
uint8_t region = h / 43; // NOLINT

0 commit comments

Comments
 (0)