mirror of
https://github.com/ohwgiles/laminar.git
synced 2024-10-27 20:34:20 +00:00
resolves #104: fix clang compiler error
provide a local typedef instead of using a pure anonymous struct also fix inconsistent whitespace
This commit is contained in:
parent
b90f49987f
commit
21c097a7a9
35
src/log.h
35
src/log.h
@ -27,23 +27,24 @@
|
||||
// paths from being encoded into the binary at all. Assumes / is the
|
||||
// path separator.
|
||||
namespace _ {
|
||||
constexpr const char* static_basename_impl(const char* b, const char* t) {
|
||||
return *t == '\0' ? b : static_basename_impl(*t == '/' ? t+1 : b, t+1);
|
||||
}
|
||||
constexpr const char* static_basename(const char* p) {
|
||||
return static_basename_impl(p, p);
|
||||
}
|
||||
constexpr int static_strlen(const char* s) {
|
||||
return *s == '\0' ? 0 : static_strlen(s + 1) + 1;
|
||||
}
|
||||
template<int N, int...I>
|
||||
static constexpr decltype(auto) static_alloc_str_impl(const char* str, std::integer_sequence<int, I...>) {
|
||||
return (struct {char buf[N+1];}) {str[I]..., 0};
|
||||
}
|
||||
template<int N>
|
||||
static constexpr decltype(auto) static_alloc_str(const char* str) {
|
||||
return static_alloc_str_impl<N>(str, std::make_integer_sequence<int, N>());
|
||||
}
|
||||
constexpr const char* static_basename_impl(const char* b, const char* t) {
|
||||
return *t == '\0' ? b : static_basename_impl(*t == '/' ? t+1 : b, t+1);
|
||||
}
|
||||
constexpr const char* static_basename(const char* p) {
|
||||
return static_basename_impl(p, p);
|
||||
}
|
||||
constexpr int static_strlen(const char* s) {
|
||||
return *s == '\0' ? 0 : static_strlen(s + 1) + 1;
|
||||
}
|
||||
template<int N, int...I>
|
||||
static constexpr decltype(auto) static_alloc_str_impl(const char* str, std::integer_sequence<int, I...>) {
|
||||
typedef struct {char buf[N+1];} static_null_terminated;
|
||||
return (static_null_terminated) {str[I]..., '\0'};
|
||||
}
|
||||
template<int N>
|
||||
static constexpr decltype(auto) static_alloc_str(const char* str) {
|
||||
return static_alloc_str_impl<N>(str, std::make_integer_sequence<int, N>());
|
||||
}
|
||||
}
|
||||
#define __FILE_BASE__ (_::static_alloc_str<_::static_strlen(_::static_basename(__FILE__))>(_::static_basename(__FILE__)).buf)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user