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)
set_target_properties(${library} PROPERTIES
VERSION ${PROJECT_VERSION}
CXX_STANDARD 20
OUTPUT_NAME "ftxui-${library}"
)

View File

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

View File

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

View File

@ -1,7 +1,9 @@
#include <array> // for array
#include <cmath> // for sin
#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 "ftxui/component/captured_mouse.hpp" // for ftxui
@ -19,12 +21,22 @@ int main(int argc, const char* argv[]) {
auto layout_horizontal = Container::Horizontal({});
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>({
.value = &values[i],
.max = 100,
.increment = 5,
.direction = GaugeDirection::Up,
}));
*/
}
layout_horizontal |= size(HEIGHT, GREATER_THAN, 20);

View File

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

View File

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

View File

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

View File

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

View File

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