opynsim
Unofficial C++ Documentation
Loading...
Searching...
No Matches
filename_extractor.h
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <string_view>
5
6namespace osc
7{
8 template<size_t N>
9 consteval std::string_view extract_filename(const char(&p)[N])
10 {
11 for (auto i = static_cast<ptrdiff_t>(N) - 2; i > 0; --i) {
12 if (p[i] == '/' or p[i] == '\\') {
13 return std::string_view{p + i + 1, static_cast<size_t>((static_cast<ptrdiff_t>(N) - 2) - i)};
14 }
15 }
16 return {p, N-1}; // else: no slashes, return as-is
17 }
18}
Definition custom_decoration_generator.h:5
constexpr U to(T &&value)
Definition conversion.h:56
consteval std::string_view extract_filename(const char(&p)[N])
Definition filename_extractor.h:9