Skip to content

Commit

Permalink
fix pretty function problem
Browse files Browse the repository at this point in the history
  • Loading branch information
jyf111 committed Nov 11, 2023
1 parent 12f6269 commit dde84dd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
21 changes: 17 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,40 @@ on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
job:
- { os: ubuntu-latest, compiler: "g++" }
- { os: ubuntu-latest, compiler: "clang++" }
- { os: macos-latest, compiler: "clang++" }
runs-on: ${{ matrix.job.os }}
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up Clang
uses: egor-tensin/setup-clang@v1
with:
version: latest
if: matrix.compiler == 'clang++'

- name: Dependencies
run: |
git config --global url.https://github.com/.insteadOf git://github.com/
git clone https://github.com/catchorg/Catch2.git --depth 1 --branch v3.4.0
cd Catch2
cmake -B build -H. -DBUILD_TESTING=OFF
cmake -B build -DBUILD_TESTING=OFF -DCMAKE_CXX_COMPILER=${{matrix.job.compiler}}
sudo cmake --build build --target install
- name: Install
run: |
cmake -B build -S .
cmake -B build -S . -DCMAKE_CXX_COMPILER=${{matrix.job.compiler}}
sudo cmake --build build --target install
- name: Test
run: |
cmake -B build -S . -DENABLE_TESTS=ON -DBUILD_EXAMPLES=on
cmake -B build -S . -DENABLE_TESTS=ON -DBUILD_EXAMPLES=on -DCMAKE_CXX_COMPILER=${{matrix.job.compiler}}
cmake --build build
cmake --build build --target test
build/examples/demo
12 changes: 12 additions & 0 deletions include/dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -149,22 +149,34 @@ template <int &...ExplicitArgumentBarrier, typename T>
requires(!std::is_enum_v<T> && !std::is_union_v<T>) std::string type_name(std::type_identity<T>) {
std::string_view pretty_name(std::source_location::current().function_name());
const auto L = pretty_name.find("T = ") + 4;
#if defined(__clang__)
const auto R = pretty_name.find_last_of(']');
#else
const auto R = pretty_name.find_last_of(';');
#endif
return std::string(pretty_name.substr(L, R - L));
}
template <is_enum Enum>
std::string type_name(std::type_identity<Enum>) {
std::string_view pretty_name(std::source_location::current().function_name());
const auto L = pretty_name.find("Enum = ") + 7;
#if defined(__clang__)
const auto R = pretty_name.find_last_of(']');
#else
const auto R = pretty_name.find_last_of(';');
#endif
return "enum " + std::string(pretty_name.substr(L, R - L)) + " : " +
type_name(std::type_identity<std::underlying_type_t<Enum>>{});
}
template <is_union Union>
std::string type_name(std::type_identity<Union>) {
std::string_view pretty_name(std::source_location::current().function_name());
const auto L = pretty_name.find("Union = ") + 8;
#if defined(__clang__)
const auto R = pretty_name.find_last_of(']');
#else
const auto R = pretty_name.find_last_of(';');
#endif
return "union " + std::string(pretty_name.substr(L, R - L));
}

Expand Down

0 comments on commit dde84dd

Please sign in to comment.