Bring back C++17 minimal requirement. (#475)

This commit is contained in:
Arthur Sonzogni 2022-09-03 12:12:59 +02:00 committed by ArthurSonzogni
parent 1d76a2321c
commit c8ec151154
No known key found for this signature in database
GPG Key ID: 41D98248C074CD6C
10 changed files with 42 additions and 33 deletions

View File

@ -9,7 +9,6 @@ endif()
function(ftxui_set_options library) function(ftxui_set_options library)
set_target_properties(${library} PROPERTIES set_target_properties(${library} PROPERTIES
VERSION ${PROJECT_VERSION} VERSION ${PROJECT_VERSION}
CXX_STANDARD 20
OUTPUT_NAME "ftxui-${library}" OUTPUT_NAME "ftxui-${library}"
) )

View File

@ -71,6 +71,7 @@ target_include_directories(tests
PRIVATE src PRIVATE src
) )
ftxui_set_options(tests) ftxui_set_options(tests)
target_compile_features(tests PUBLIC cxx_std_20)
include(GoogleTest) include(GoogleTest)
gtest_discover_tests(tests gtest_discover_tests(tests

View File

@ -1,7 +1,7 @@
codecov: codecov:
require_ci_to_pass: no require_ci_to_pass: no
notify: notify:
after_n_builds: 3 after_n_builds: 4
wait_for_ci: yes wait_for_ci: yes
coverage: coverage:

View File

@ -1,7 +1,9 @@
#include <array> // for array #include <array> // for array
#include <cmath> // for sin #include <cmath> // for sin
#include <ftxui/component/component_base.hpp> // for ComponentBase #include <ftxui/component/component_base.hpp> // for ComponentBase
#include <ftxui/dom/elements.hpp> // for size, GaugeDirection, GaugeDirection::Up, GREATER_THAN, HEIGHT #include <ftxui/component/component_options.hpp> // for SliderOption
#include <ftxui/dom/elements.hpp> // for size, GREATER_THAN, GaugeDirection, GaugeDirection::Up, HEIGHT
#include <ftxui/util/ref.hpp> // for ConstRef, Ref
#include <memory> // for shared_ptr, __shared_ptr_access #include <memory> // for shared_ptr, __shared_ptr_access
#include "ftxui/component/captured_mouse.hpp" // for ftxui #include "ftxui/component/captured_mouse.hpp" // for ftxui
@ -19,12 +21,22 @@ int main(int argc, const char* argv[]) {
auto layout_horizontal = Container::Horizontal({}); auto layout_horizontal = Container::Horizontal({});
for (int i = 0; i < values.size(); ++i) { for (int i = 0; i < values.size(); ++i) {
// In C++17:
SliderOption<int> option;
option.value = &values[i];
option.max = 100;
option.increment = 5;
option.direction = GaugeDirection::Up;
layout_horizontal->Add(Slider<int>(option));
/* In C++20:
layout_horizontal->Add(Slider<int>({ layout_horizontal->Add(Slider<int>({
.value = &values[i], .value = &values[i],
.max = 100, .max = 100,
.increment = 5, .increment = 5,
.direction = GaugeDirection::Up, .direction = GaugeDirection::Up,
})); }));
*/
} }
layout_horizontal |= size(HEIGHT, GREATER_THAN, 20); layout_horizontal |= size(HEIGHT, GREATER_THAN, 20);

View File

@ -2,7 +2,7 @@
#define FTXUI_SCREEN_SCREEN_HPP #define FTXUI_SCREEN_SCREEN_HPP
#include <memory> #include <memory>
#include <string> // for allocator, string, basic_string #include <string> // for string, allocator, basic_string
#include <vector> // for vector #include <vector> // for vector
#include "ftxui/screen/box.hpp" // for Box #include "ftxui/screen/box.hpp" // for Box

View File

@ -1,5 +1,4 @@
#include <cmath> // IWYU pragma: keep #include <cmath> // IWYU pragma: keep
#include <compare> // for operator<=, operator>=, partial_ordering
#include <ratio> // for ratio #include <ratio> // for ratio
#include <utility> // for move #include <utility> // for move

View File

@ -26,8 +26,7 @@ class RadioboxBase : public ComponentBase {
RadioboxBase(ConstStringListRef entries, RadioboxBase(ConstStringListRef entries,
int* selected, int* selected,
Ref<RadioboxOption> option) Ref<RadioboxOption> option)
: entries_(entries), selected_(selected), option_(std::move(option)) { : entries_(entries), selected_(selected), option_(std::move(option)) {}
}
private: private:
Element Render() override { Element Render() override {

View File

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

View File

@ -266,12 +266,12 @@ Component Slider(ConstStringRef label,
ConstRef<int> min, ConstRef<int> min,
ConstRef<int> max, ConstRef<int> max,
ConstRef<int> increment) { ConstRef<int> increment) {
auto slider = Make<SliderBase<int>>(SliderOption<int>({ SliderOption<int> option;
.value = value, option.value = value;
.min = min, option.min = min;
.max = max, option.max = max;
.increment = increment, option.increment = increment;
})); auto slider = Make<SliderBase<int>>(option);
return Make<SliderWithLabel>(label, slider); return Make<SliderWithLabel>(label, slider);
} }
@ -280,12 +280,12 @@ Component Slider(ConstStringRef label,
ConstRef<float> min, ConstRef<float> min,
ConstRef<float> max, ConstRef<float> max,
ConstRef<float> increment) { ConstRef<float> increment) {
auto slider = Make<SliderBase<float>>(SliderOption<float>({ SliderOption<float> option;
.value = value, option.value = value;
.min = min, option.min = min;
.max = max, option.max = max;
.increment = increment, option.increment = increment;
})); auto slider = Make<SliderBase<float>>(option);
return Make<SliderWithLabel>(label, slider); return Make<SliderWithLabel>(label, slider);
} }
Component Slider(ConstStringRef label, Component Slider(ConstStringRef label,
@ -293,12 +293,12 @@ Component Slider(ConstStringRef label,
ConstRef<long> min, ConstRef<long> min,
ConstRef<long> max, ConstRef<long> max,
ConstRef<long> increment) { ConstRef<long> increment) {
auto slider = Make<SliderBase<long>>(SliderOption<long>({ SliderOption<long> option;
.value = value, option.value = value;
.min = min, option.min = min;
.max = max, option.max = max;
.increment = increment, option.increment = increment;
})); auto slider = Make<SliderBase<long>>(option);
return Make<SliderWithLabel>(label, slider); return Make<SliderWithLabel>(label, slider);
} }