From 90f271961f9335d74fdf9aab84543de133367686 Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Mon, 11 Dec 2023 17:52:24 -0500 Subject: [PATCH] visit --- include/blt/std/utility.h | 6 +++++- src/blt/std/format.cpp | 16 ++++++++-------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/include/blt/std/utility.h b/include/blt/std/utility.h index d05f4f6..bbf8679 100644 --- a/include/blt/std/utility.h +++ b/include/blt/std/utility.h @@ -208,7 +208,11 @@ namespace blt return range_itr(_end - offset, offset == 0); } }; - + +//#define BLT_LAMBDA(type, var, code) [](const type& var) -> auto { return code; } +//#define BLT_LAMBDA(var, code) [](var) -> auto { return code; } + +// TODO: WTF template struct lambda_visitor : TLambdas... { using TLambdas::operator()...; diff --git a/src/blt/std/format.cpp b/src/blt/std/format.cpp index 82a59f6..e0c3ba9 100755 --- a/src/blt/std/format.cpp +++ b/src/blt/std/format.cpp @@ -451,9 +451,9 @@ namespace blt // if one of the strings are larger than there will be a misalignment as the width of the box is based on the largest string // so we need to add an offset to the smallest string for centering. if (box.data.length() > box.title.length()) - titlePad += (box.data.length() - box.title.length())/2; + titlePad += (box.data.length() - box.title.length()) / 2; else - dataPad += (box.title.length() - box.data.length())/2; + dataPad += (box.title.length() - box.data.length()) / 2; // copy in the title and data string for (size_t i = 0; i < box.title.size(); i++) @@ -467,13 +467,13 @@ namespace blt blt::string::ascii_data blt::string::constructBox(const blt::string::box_type& box) { auto width = std::visit(blt::lambda_visitor{ - [](const blt::string::ascii_box& box) -> size_t {return box.width();}, - [](const blt::string::ascii_boxes& boxes) -> size_t {return boxes.width();} - }, box); + [](const blt::string::ascii_box& box) -> size_t { return box.width(); }, + [](const blt::string::ascii_boxes& boxes) -> size_t { return boxes.width(); } + }, box); auto height = std::visit(blt::lambda_visitor{ - [](const blt::string::ascii_box& box) -> size_t {return box.height();}, - [](const blt::string::ascii_boxes& boxes) -> size_t {return boxes.height();} - }, box); + [](const blt::string::ascii_box& box) -> size_t { return box.height(); }, + [](const blt::string::ascii_boxes& boxes) -> size_t { return boxes.height(); } + }, box); string::ascii_data data(width, height);