From 33db44d2832f8097f1fb2c1b65276cbf85d0ef84 Mon Sep 17 00:00:00 2001 From: John Sallay Date: Tue, 11 Jun 2024 22:19:25 -0400 Subject: [PATCH 01/14] Don't use std::visit for formatting. It is too slow and complex Signed-off-by: John Sallay --- include/pmtv/format.hpp | 94 +++++++++++++++-------------------------- 1 file changed, 35 insertions(+), 59 deletions(-) diff --git a/include/pmtv/format.hpp b/include/pmtv/format.hpp index feba6f4..70cb202 100644 --- a/include/pmtv/format.hpp +++ b/include/pmtv/format.hpp @@ -45,66 +45,42 @@ struct formatter

template auto format(const P& value, FormatContext& ctx) const { - // Due to an issue with the c++ spec that has since been resolved, we have to do something - // funky here. See - // https://stackoverflow.com/questions/37526366/nested-constexpr-function-calls-before-definition-in-a-constant-expression-con - // This problem only appears to occur in gcc 11 in certain optimization modes. The problem - // occurs when we want to format a vector. Ideally, we can write something like: - // return fmt::format_to(ctx.out(), "[{}]", fmt::join(arg, ", ")); - // It looks like the issue effects clang 14/15 as well. - // However, due to the above issue, it fails to compile. So we have to do the equivalent - // ourselves. We can't recursively call the formatter, but we can recursively call a lambda - // function that does the formatting. - // It gets more complicated, because we need to pass the function into the lambda. We can't - // pass in the lamdba as it is defined, so we create a nested lambda. Which accepts a function - // as a argument. - // Because we are calling std::visit, we can't pass non-variant arguments to the visitor, so we - // have to create a new nested lambda every time we format a vector to ensure that it works. + // Using visit here is fairly slow. It is probably because of the recursive nature of it. + // It is really simple to enumerate the possibilities here. using namespace pmtv; - using ret_type = decltype(fmt::format_to(ctx.out(), "")); - auto format_func = [&ctx](const auto format_arg) { - auto function_main = [&ctx](const auto arg, auto function) -> ret_type { - using namespace pmtv; - using T = std::decay_t; - if constexpr (Scalar || Complex) - return fmt::format_to(ctx.out(), "{}", arg); - else if constexpr (std::same_as) - return fmt::format_to(ctx.out(), "{}", arg); - else if constexpr (UniformVector || UniformStringVector) - return fmt::format_to(ctx.out(), "[{}]", fmt::join(arg, ", ")); - else if constexpr (std::same_as>) { - fmt::format_to(ctx.out(), "["); - auto new_func = [&function](const auto new_arg) -> ret_type { return function(new_arg, function); }; - for (auto& a: std::span(arg).first(arg.size()-1)) { - std::visit(new_func, a); - fmt::format_to(ctx.out(), ", "); - } - std::visit(new_func, arg[arg.size()-1]); - return fmt::format_to(ctx.out(), "]"); - // When we drop support for gcc11/clang15, get rid of the nested lambda and replace - // the above with this line. - //return fmt::format_to(ctx.out(), "[{}]", fmt::join(arg, ", ")); - } else if constexpr (PmtMap) { - fmt::format_to(ctx.out(), "{{"); - auto new_func = [&function](const auto new_arg) -> ret_type { return function(new_arg, function); }; - size_t i = 0; - for (auto& [k, v]: arg) { - fmt::format_to(ctx.out(), "{}: ", k); - std::visit(new_func, v); - if (i++ < arg.size() - 1) - fmt::format_to(ctx.out(), ", "); - } - return fmt::format_to(ctx.out(), "}}"); - // When we drop support for gcc11/clang15, get rid of the nested lambda and replace - // the above with this line. - //return fmt::format_to(ctx.out(), "{{{}}}", fmt::join(arg, ", ")); - } else if constexpr (std::same_as) - return fmt::format_to(ctx.out(), "null"); - return fmt::format_to(ctx.out(), "unknown type {}", typeid(T).name()); - }; - return function_main(format_arg, function_main); - }; - return std::visit(format_func, value); + if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "null"); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "{}", std::get>(value)); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "{}", std::get>(value)); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>>(value), ", ")); + else if (std::holds_alternative>>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>>(value), ", ")); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{{{}}}", fmt::join(std::get(value), ", ")); + //static_assert(false); + return fmt::format_to(ctx.out(), "error"); } }; From 6163d98124a1b3d84a190a5b76a9a0751b6e882d Mon Sep 17 00:00:00 2001 From: John Sallay Date: Tue, 11 Jun 2024 22:42:51 -0400 Subject: [PATCH 02/14] Try to make some compilers happy Signed-off-by: John Sallay --- include/pmtv/format.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pmtv/format.hpp b/include/pmtv/format.hpp index 70cb202..67806e4 100644 --- a/include/pmtv/format.hpp +++ b/include/pmtv/format.hpp @@ -77,7 +77,7 @@ struct formatter

else if (std::holds_alternative>>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>>(value), ", ")); else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{{{}}}", fmt::join(std::get(value), ", ")); //static_assert(false); return fmt::format_to(ctx.out(), "error"); From 950c7759239fa70177abc32493e22b7520725bbe Mon Sep 17 00:00:00 2001 From: John Sallay Date: Tue, 11 Jun 2024 22:47:33 -0400 Subject: [PATCH 03/14] Try to make some compilers happy Signed-off-by: John Sallay --- include/pmtv/format.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pmtv/format.hpp b/include/pmtv/format.hpp index 67806e4..dd770d8 100644 --- a/include/pmtv/format.hpp +++ b/include/pmtv/format.hpp @@ -77,7 +77,7 @@ struct formatter

else if (std::holds_alternative>>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>>(value), ", ")); else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); + else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{{{}}}", fmt::join(std::get(value), ", ")); //static_assert(false); return fmt::format_to(ctx.out(), "error"); From 332fd82880c36111acc3fd1f1bd1fc47ee7a2fd5 Mon Sep 17 00:00:00 2001 From: John Sallay Date: Mon, 1 Jul 2024 21:14:01 -0400 Subject: [PATCH 04/14] Try updating base image and compiler Signed-off-by: John Sallay --- .github/workflows/build_and_test.yml | 12 ++++++------ .github/workflows/emscripten.yml | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index cea052e..28cde9b 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -9,7 +9,7 @@ on: jobs: linux-docker: # All of these shall depend on the formatting check (needs: check-formatting) - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 # The GH default is 360 minutes (it's also the max as of Feb-2021). However, # we should fail sooner. The only reason to exceed this time is if a test # hangs. @@ -23,12 +23,12 @@ jobs: # descriptive name, and one key 'containerid' with the name of the # container (i.e., what you want to docker-pull) distro: - - name: 'Ubuntu 22.04' - containerid: 'ghcr.io/gnuradio/gnuradio-docker:ubuntu-22.04' + - name: 'Ubuntu 24.04' + containerid: 'ghcr.io/fair-acc/gr4-build-container:latest' cxxflags: -Werror - - name: 'Fedora 36' - containerid: 'ghcr.io/gnuradio/gnuradio-docker:fedora-36' - cxxflags: '' + #- name: 'Fedora 36' + # containerid: 'ghcr.io/gnuradio/gnuradio-docker:fedora-36' + # cxxflags: '' # - distro: 'CentOS 8.3' # containerid: 'gnuradio/ci:centos-8.3-3.9' # cxxflags: -Werror diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 1ce74cb..13f09ab 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -23,8 +23,8 @@ jobs: # descriptive name, and one key 'containerid' with the name of the # container (i.e., what you want to docker-pull) distro: - - name: 'Ubuntu 22.04' - containerid: 'ghcr.io/gnuradio/gnuradio-docker:ubuntu-22.04' + - name: 'Ubuntu 24.04' + containerid: 'ghcr.io/fair-acc/gr4-build-container:latest' cxxflags: -Werror compiler: - name: "emscripten" From 35cfe8a69e5b978ed228b0b24776a75bf2192c6a Mon Sep 17 00:00:00 2001 From: John Sallay Date: Mon, 1 Jul 2024 21:19:32 -0400 Subject: [PATCH 05/14] Install meson and ninja in new container Signed-off-by: John Sallay --- .github/workflows/build_and_test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 28cde9b..21e2cda 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -49,6 +49,8 @@ jobs: steps: - uses: actions/checkout@v3 name: Checkout Project + - name: install deps + run: apt-get update && apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build - name: Meson Setup env: CXX: ${{ matrix.compiler.command }} From c943b815ede99e143e5eacbae06363aa024fbead Mon Sep 17 00:00:00 2001 From: John Sallay Date: Mon, 1 Jul 2024 21:21:52 -0400 Subject: [PATCH 06/14] Add sudo on installs Signed-off-by: John Sallay --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 21e2cda..5ec8d71 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -50,7 +50,7 @@ jobs: - uses: actions/checkout@v3 name: Checkout Project - name: install deps - run: apt-get update && apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build + run: sudo apt-get update && sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build - name: Meson Setup env: CXX: ${{ matrix.compiler.command }} From ab67d8e2aa3c0a183cb8486245888a42e2ceb200 Mon Sep 17 00:00:00 2001 From: John Sallay Date: Mon, 1 Jul 2024 21:24:04 -0400 Subject: [PATCH 07/14] Need one more package Signed-off-by: John Sallay --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index 5ec8d71..b9819c5 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -50,7 +50,7 @@ jobs: - uses: actions/checkout@v3 name: Checkout Project - name: install deps - run: sudo apt-get update && sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build + run: sudo apt-get update && sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build && pip3 install meson --break-system-packages - name: Meson Setup env: CXX: ${{ matrix.compiler.command }} From 4b145badbb7236dbd8f60d4fd0d1863245c787f3 Mon Sep 17 00:00:00 2001 From: John Sallay Date: Mon, 1 Jul 2024 21:25:31 -0400 Subject: [PATCH 08/14] Need to add sudo Signed-off-by: John Sallay --- .github/workflows/build_and_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index b9819c5..e8c6771 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -50,7 +50,7 @@ jobs: - uses: actions/checkout@v3 name: Checkout Project - name: install deps - run: sudo apt-get update && sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build && pip3 install meson --break-system-packages + run: sudo apt-get update && sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build && sudo pip3 install meson --break-system-packages - name: Meson Setup env: CXX: ${{ matrix.compiler.command }} From ce4fa6e03f4a1f6420ce2ce248d3561a8a1afb39 Mon Sep 17 00:00:00 2001 From: John Sallay Date: Thu, 4 Jul 2024 06:08:32 -0400 Subject: [PATCH 09/14] Use new gnuradio images Signed-off-by: John Sallay --- .github/workflows/build_and_test.yml | 10 ++++------ .github/workflows/emscripten.yml | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_and_test.yml b/.github/workflows/build_and_test.yml index e8c6771..054046d 100644 --- a/.github/workflows/build_and_test.yml +++ b/.github/workflows/build_and_test.yml @@ -24,11 +24,11 @@ jobs: # container (i.e., what you want to docker-pull) distro: - name: 'Ubuntu 24.04' - containerid: 'ghcr.io/fair-acc/gr4-build-container:latest' + containerid: 'ghcr.io/gnuradio/gnuradio-docker:ubuntu-24.04' cxxflags: -Werror - #- name: 'Fedora 36' - # containerid: 'ghcr.io/gnuradio/gnuradio-docker:fedora-36' - # cxxflags: '' + - name: 'Fedora 40' + containerid: 'ghcr.io/gnuradio/gnuradio-docker:fedora-40' + cxxflags: '' # - distro: 'CentOS 8.3' # containerid: 'gnuradio/ci:centos-8.3-3.9' # cxxflags: -Werror @@ -49,8 +49,6 @@ jobs: steps: - uses: actions/checkout@v3 name: Checkout Project - - name: install deps - run: sudo apt-get update && sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build && sudo pip3 install meson --break-system-packages - name: Meson Setup env: CXX: ${{ matrix.compiler.command }} diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 13f09ab..35b4b5d 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -24,7 +24,7 @@ jobs: # container (i.e., what you want to docker-pull) distro: - name: 'Ubuntu 24.04' - containerid: 'ghcr.io/fair-acc/gr4-build-container:latest' + containerid: 'ghcr.io/gnuradio/gnuradio-docker:ubuntu-24.04' cxxflags: -Werror compiler: - name: "emscripten" From 357b37af6dbcd50c1465825db412bb5bbb715b34 Mon Sep 17 00:00:00 2001 From: John Sallay Date: Thu, 4 Jul 2024 08:13:58 -0400 Subject: [PATCH 10/14] Needed to change name in one more place Signed-off-by: John Sallay --- .github/workflows/emscripten.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 35b4b5d..93906cb 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -9,7 +9,7 @@ on: jobs: linux-docker: # All of these shall depend on the formatting check (needs: check-formatting) - runs-on: ubuntu-22.04 + runs-on: ubuntu-24.04 # The GH default is 360 minutes (it's also the max as of Feb-2021). However, # we should fail sooner. The only reason to exceed this time is if a test # hangs. From ddae978807bcb630558f6475254f8d6097ea2f26 Mon Sep 17 00:00:00 2001 From: John Sallay Date: Fri, 5 Jul 2024 21:27:25 -0400 Subject: [PATCH 11/14] Need to use std::visit to make compiler happy Signed-off-by: John Sallay --- include/pmtv/format.hpp | 53 +++++++++++++---------------------------- meson.build | 2 +- 2 files changed, 18 insertions(+), 37 deletions(-) diff --git a/include/pmtv/format.hpp b/include/pmtv/format.hpp index dd770d8..dc5dc3d 100644 --- a/include/pmtv/format.hpp +++ b/include/pmtv/format.hpp @@ -45,42 +45,23 @@ struct formatter

template auto format(const P& value, FormatContext& ctx) const { - // Using visit here is fairly slow. It is probably because of the recursive nature of it. - // It is really simple to enumerate the possibilities here. - using namespace pmtv; - if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "null"); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "{}", std::get>(value)); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "{}", std::get>(value)); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>>(value), ", ")); - else if (std::holds_alternative>>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>>(value), ", ")); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{}", std::get(value)); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative>(value)) return fmt::format_to(ctx.out(), "[{}]", fmt::join(std::get>(value), ", ")); - else if (std::holds_alternative(value)) return fmt::format_to(ctx.out(), "{{{}}}", fmt::join(std::get(value), ", ")); - //static_assert(false); - return fmt::format_to(ctx.out(), "error"); + return std::visit([&ctx](const auto arg) { + using namespace pmtv; + using T = std::decay_t; + if constexpr (Scalar || Complex) + return fmt::format_to(ctx.out(), "{}", arg); + else if constexpr (std::same_as) + return fmt::format_to(ctx.out(), "{}", arg); + else if constexpr (UniformVector || UniformStringVector) + return fmt::format_to(ctx.out(), "[{}]", fmt::join(arg, ", ")); + else if constexpr (std::same_as>) { + return fmt::format_to(ctx.out(), "[{}]", fmt::join(arg, ", ")); + } else if constexpr (PmtMap) { + return fmt::format_to(ctx.out(), "{{{}}}", fmt::join(arg, ", ")); + } else if constexpr (std::same_as) + return fmt::format_to(ctx.out(), "null"); + return fmt::format_to(ctx.out(), "unknown type {}", typeid(T).name()); + }, value); } }; diff --git a/meson.build b/meson.build index 8b1d886..08bd4f2 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project('pmt', 'cpp', version : '0.0.2', meson_version: '>=0.63.0', license : 'GPLv3', - default_options : ['cpp_std=c++20', 'warning_level=3']) + default_options : ['cpp_std=c++23', 'warning_level=3']) cc = meson.get_compiler('cpp') warnings_as_errors = get_option('warnings_as_errors') # Define this option in your meson_options.txt From 4f433ef8deeaff1ac0b36c9a5940ebb3d533c5ca Mon Sep 17 00:00:00 2001 From: John Sallay Date: Sat, 21 Sep 2024 08:13:49 -0400 Subject: [PATCH 12/14] Update fmt dep so that we can compile everywhere Signed-off-by: John Sallay --- include/pmtv/format.hpp | 1 + meson.build | 2 +- subprojects/fmt.wrap | 16 ++++++++-------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/include/pmtv/format.hpp b/include/pmtv/format.hpp index dc5dc3d..0893ecb 100644 --- a/include/pmtv/format.hpp +++ b/include/pmtv/format.hpp @@ -2,6 +2,7 @@ // Gcc12 does not support it. // Eventually replace with std::format when that is widely available. #include +#include namespace fmt { template <> diff --git a/meson.build b/meson.build index 08bd4f2..b81d7b8 100644 --- a/meson.build +++ b/meson.build @@ -98,7 +98,7 @@ endif gtest_dep = dependency('gtest', main : true, version : '>=1.10', required : get_option('enable_testing')) gtest_main_dep = dependency('gtest_main', version : '>=1.10', required : get_option('enable_testing')) CLI11_dep = dependency('CLI11', fallback : [ 'cli11' , 'CLI11_dep' ]) -fmt_dep = dependency('fmt', version:'>=8.1.1') +fmt_dep = dependency('fmt', version:'>=10.0.0') cmake = import('cmake') diff --git a/subprojects/fmt.wrap b/subprojects/fmt.wrap index a0782aa..7a0f1bb 100644 --- a/subprojects/fmt.wrap +++ b/subprojects/fmt.wrap @@ -1,12 +1,12 @@ [wrap-file] -directory = fmt-8.1.1 -source_url = https://github.com/fmtlib/fmt/archive/8.1.1.tar.gz -source_filename = fmt-8.1.1.tar.gz -source_hash = 3d794d3cf67633b34b2771eb9f073bde87e846e0d395d254df7b211ef1ec7346 -patch_filename = fmt_8.1.1-2_patch.zip -patch_url = https://wrapdb.mesonbuild.com/v2/fmt_8.1.1-2/get_patch -patch_hash = cd001046281330a8862591780a9ea71a1fa594edd0d015deb24e44680c9ea33b -wrapdb_version = 8.1.1-2 +directory = fmt-11.0.2 +source_url = https://github.com/fmtlib/fmt/archive/11.0.2.tar.gz +source_filename = fmt-11.0.2.tar.gz +source_hash = 6cb1e6d37bdcb756dbbe59be438790db409cdb4868c66e888d5df9f13f7c027f +patch_filename = fmt_11.0.2-1_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/fmt_11.0.2-1/get_patch +patch_hash = 90c9e3b8e8f29713d40ca949f6f93ad115d78d7fb921064112bc6179e6427c5e +wrapdb_version = 11.0.2-1 [provide] fmt = fmt_dep \ No newline at end of file From 9a115263f7ba22b37ebcc91d7f3143dac70ad230 Mon Sep 17 00:00:00 2001 From: John Sallay Date: Sat, 21 Sep 2024 08:40:30 -0400 Subject: [PATCH 13/14] Install clang in emscripten jobs Signed-off-by: John Sallay --- .github/workflows/emscripten.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml index 93906cb..1e2ad8c 100644 --- a/.github/workflows/emscripten.yml +++ b/.github/workflows/emscripten.yml @@ -40,7 +40,7 @@ jobs: name: Checkout Project - name: Install emscripten run: | - DEBIAN_FRONTEND=noninteractive apt-get install -qy bzip2 + DEBIAN_FRONTEND=noninteractive apt-get install -qy bzip2 clang cd git clone https://github.com/emscripten-core/emsdk.git cd emsdk From c1a1bbd415dc6a09b6ed49a845132d115f5ed702 Mon Sep 17 00:00:00 2001 From: John Sallay Date: Fri, 27 Sep 2024 21:01:07 -0400 Subject: [PATCH 14/14] Only require c++20. Signed-off-by: John Sallay --- meson.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meson.build b/meson.build index b81d7b8..1dfae18 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project('pmt', 'cpp', version : '0.0.2', meson_version: '>=0.63.0', license : 'GPLv3', - default_options : ['cpp_std=c++23', 'warning_level=3']) + default_options : ['cpp_std=c++20', 'warning_level=3']) cc = meson.get_compiler('cpp') warnings_as_errors = get_option('warnings_as_errors') # Define this option in your meson_options.txt