-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
267 additions
and
389 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#pragma once | ||
|
||
#include <string_view> | ||
#include <source_location> | ||
|
||
namespace rebind::impl | ||
{ | ||
template <auto I> | ||
using constant = std::integral_constant<decltype(I), I>; | ||
|
||
template <auto T> | ||
consteval std::string_view mangled_name() | ||
{ | ||
return std::source_location::current().function_name(); | ||
} | ||
|
||
template <typename U> | ||
consteval auto unmangle(std::string_view name, U decorators) | ||
{ | ||
const auto start = name.substr(name.rfind(decorators.first) + decorators.first.size()); | ||
const auto end = start.substr(0, start.rfind(decorators.second)); | ||
|
||
return end; | ||
} | ||
|
||
template <typename... Ts> | ||
consteval auto remove_prefix(std::string_view name, Ts &&...prefixes) | ||
{ | ||
const auto has_prefix = (name.starts_with(prefixes) || ...); | ||
|
||
if (!has_prefix) | ||
{ | ||
return name; | ||
} | ||
|
||
return name.substr(name.find(' ') + 1); | ||
} | ||
|
||
consteval auto remove_type(std::string_view name, std::string_view type, std::string_view delim) | ||
{ | ||
const auto start = name.substr(name.rfind(type) + type.size()); | ||
const auto end = start.rfind(delim); | ||
|
||
if (end == std::string_view::npos) | ||
{ | ||
return std::string_view{}; | ||
} | ||
else | ||
{ | ||
return start.substr(end + delim.size()); | ||
} | ||
} | ||
} // namespace rebind::impl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.