44 template <
typename... Tp>
45 struct source_location_constant_char;
48 struct source_location_constant_char<>
50 static constexpr
bool value =
true;
54 struct source_location_constant_char<const char*>
56 static constexpr
bool value =
true;
59 template <
typename Tp>
60 struct source_location_constant_char<Tp>
62 static constexpr
bool value = std::is_same<Tp, const char*>::value;
65 template <
typename Tp,
typename Up,
typename... Tail>
66 struct source_location_constant_char<Tp, Up, Tail...>
68 static constexpr
bool value = source_location_constant_char<Tp>::value &&
69 source_location_constant_char<Up>::value &&
70 source_location_constant_char<Tail...>::value;
85 template <
typename... Tp>
86 static constexpr
bool is_constant_char()
88 return impl::source_location_constant_char<decay_t<Tp>...>::value;
116 : m_result(std::move(_result))
125 template <
typename... ArgsT,
enable_if_t<(
sizeof...(ArgsT) > 0),
int> = 0>
156 template <
typename... ArgsT,
enable_if_t<
sizeof...(ArgsT) == 0,
int> = 0>
172 template <
typename... ArgsT>
174 const char* _fname, ArgsT&&... _args)
177 std::forward<ArgsT>(_args)... };
178 return _loc.get_captured(std::forward<ArgsT>(_args)...);
188 template <
typename... ArgsT,
enable_if_t<!is_constant_char<ArgsT...>(),
int> = 0>
207 template <
typename... ArgsT,
enable_if_t<is_constant_char<ArgsT...>(),
int> = 0>
218 auto&& _label = _arg;
226 auto&& _label = _join(_arg.c_str());
236 auto&& _label = _join(_arg.c_str());
260 void compute_data(
const char* _func,
int _line,
const char* _fname,
bool shorten)
262 #if defined(TIMEMORY_WINDOWS)
263 static const char delim =
'\\';
265 static const char delim =
'/';
270 if(_filename.find(delim) != std::string::npos)
271 _filename = _filename.substr(_filename.find_last_of(delim) + 1);
276 if(_filename.length() > 0)
287 if(_filename.length() > 0)
303 enable_if_t<(
sizeof...(ArgsT) > 0) && !is_constant_char<ArgsT...>(),
int> = 0>
306 return m_captured.set(*
this, std::forward<ArgsT>(_args)...);
317 enable_if_t<(
sizeof...(ArgsT) > 0) && is_constant_char<ArgsT...>(),
int> = 0>
331 return (strcmp(_arg,
"") == 0) ? m_prefix
342 template <size_t, size_t,
typename... Args>
344 get_static_source_location(Args&&... args)
346 static source_location _instance{ std::forward<Args>(args)... };
357 template <
size_t LineN,
size_t CountN,
typename... Args>
359 get_static_source_location(Args&&... args)
361 return internal::get_static_source_location<LineN, CountN>(
362 std::forward<Args>(args)...);
Provides source location information and variadic joining of source location tags.
const captured & get_captured() const
static captured get_captured_inline(const mode &_mode, const char *_func, int _line, const char *_fname, ArgsT &&... _args)
source_location(const source_location &)=delete
source_location(source_location &&)=default
mpl::apply< std::string > join_type
void compute_data(const char *_func, int _line, const char *_fname, bool shorten)
const captured & get_captured(ArgsT &&... _args)
void compute_data(const char *_func)
~source_location()=default
std::tuple< std::string, size_t > result_type
const captured & get_captured(ArgsT &&...)
source_location(const mode &_mode, const char *_func, int _line, const char *_fname, ArgsT &&... _args)
source_location & operator=(source_location &&)=default
source_location(const mode &_mode, const char *_func, int _line, const char *_fname, ArgsT &&...)
source_location & operator=(const source_location &)=delete
auto join(const char *sep, Arg &&arg, Args &&... args)
void consume_parameters(ArgsT &&...) TIMEMORY_HIDDEN
typename std::enable_if< B, T >::type enable_if_t
Alias template for enable_if.
tim::mpl::apply< std::string > string
hash_value_t add_hash_id(hash_map_ptr_t &_hash_map, const string_view_t &_prefix)
add an string to the given hash-map (if it doesn't already exist) and return the hash
char const std::string const std::string & _suffix
const std::string & get_id() const
friend class source_location
const result_type & get() const
const hash_value_t & get_hash() const
captured(result_type _result)