mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-12-16 01:48:56 +08:00
Add string view overloads (#1154)
Some checks failed
Build / Bazel, cl, windows-latest (push) Has been cancelled
Build / Bazel, clang++, macos-latest (push) Has been cancelled
Build / Bazel, clang++, ubuntu-latest (push) Has been cancelled
Build / Bazel, g++, macos-latest (push) Has been cancelled
Build / Bazel, g++, ubuntu-latest (push) Has been cancelled
Build / CMake, cl, windows-latest (push) Has been cancelled
Build / CMake, gcc, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, macos-latest (push) Has been cancelled
Build / Test modules (llvm, ubuntu-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
Some checks failed
Build / Bazel, cl, windows-latest (push) Has been cancelled
Build / Bazel, clang++, macos-latest (push) Has been cancelled
Build / Bazel, clang++, ubuntu-latest (push) Has been cancelled
Build / Bazel, g++, macos-latest (push) Has been cancelled
Build / Bazel, g++, ubuntu-latest (push) Has been cancelled
Build / CMake, cl, windows-latest (push) Has been cancelled
Build / CMake, gcc, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, ubuntu-latest (push) Has been cancelled
Build / CMake, llvm, macos-latest (push) Has been cancelled
Build / Test modules (llvm, ubuntu-latest) (push) Has been cancelled
Documentation / documentation (push) Has been cancelled
This is better ergonomic, as `std::string_view` is lightweight and accept more conversion than `const std::string&`. Co-authored-by: ArthurSonzogni <sonzogniarthur@gmail.com>
This commit is contained in:
@@ -48,8 +48,8 @@ class Hyperlink : public NodeDecorator {
|
||||
/// Element document =
|
||||
/// hyperlink("https://github.com/ArthurSonzogni/FTXUI", "link");
|
||||
/// ```
|
||||
Element hyperlink(std::string link, Element child) {
|
||||
return std::make_shared<Hyperlink>(std::move(child), std::move(link));
|
||||
Element hyperlink(std::string_view link, Element child) {
|
||||
return std::make_shared<Hyperlink>(std::move(child), std::string(link));
|
||||
}
|
||||
|
||||
/// @brief Decorate using a hyperlink.
|
||||
@@ -67,8 +67,10 @@ Element hyperlink(std::string link, Element child) {
|
||||
/// text("red") | hyperlink("https://github.com/Arthursonzogni/FTXUI");
|
||||
/// ```
|
||||
// NOLINTNEXTLINE
|
||||
Decorator hyperlink(std::string link) {
|
||||
return [link](Element child) { return hyperlink(link, std::move(child)); };
|
||||
Decorator hyperlink(std::string_view link) {
|
||||
return [link = std::string(link)](Element child) {
|
||||
return hyperlink(link, std::move(child));
|
||||
};
|
||||
}
|
||||
|
||||
} // namespace ftxui
|
||||
|
||||
Reference in New Issue
Block a user