tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
source_location.hpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSL-1.0
2
3#ifndef TETL_SOURCE_LOCATION_SOURCE_LOCATION_HPP
4#define TETL_SOURCE_LOCATION_SOURCE_LOCATION_HPP
5
6#include <etl/_config/all.hpp>
7
10
11namespace etl {
12
13#if defined(__cpp_consteval)
14
22 [[nodiscard]] static consteval auto current(
25 char const* const file = TETL_BUILTIN_FILE(),
26 char const* const function = TETL_BUILTIN_FUNCTION()
27 ) noexcept -> source_location
28 {
29 auto result = source_location{};
30 result._line = line;
31 result._column = column;
32 result._file = file;
33 result._function = function;
34 return result;
35 }
36
37 constexpr source_location() noexcept = default;
38
39 [[nodiscard]] constexpr auto line() const noexcept -> etl::uint_least32_t { return _line; }
40
41 [[nodiscard]] constexpr auto column() const noexcept -> etl::uint_least32_t { return _column; }
42
43 [[nodiscard]] constexpr auto file_name() const noexcept -> char const* { return _file; }
44
45 [[nodiscard]] constexpr auto function_name() const noexcept -> char const* { return _function; }
46
47private:
48 etl::uint_least32_t _line{};
49 etl::uint_least32_t _column{};
50 char const* _file = "";
51 char const* _function = "";
52};
53
54#endif
55
56} // namespace etl
57
58#endif // TETL_SOURCE_LOCATION_SOURCE_LOCATION_HPP
#define TETL_BUILTIN_FUNCTION()
Definition builtin_functions.hpp:27
#define TETL_BUILTIN_COLUMN()
Definition builtin_functions.hpp:9
#define TETL_BUILTIN_FILE()
Definition builtin_functions.hpp:21
#define TETL_BUILTIN_LINE()
Definition builtin_functions.hpp:15
Definition adjacent_find.hpp:8
TETL_BUILTIN_UINT32 uint_least32_t
Signed integer type with width of at least 32 bits.
Definition uint_least_t.hpp:17
static consteval auto current(uint_least32_t const line=TETL_BUILTIN_LINE(), uint_least32_t const column=TETL_BUILTIN_COLUMN(), char const *const file=TETL_BUILTIN_FILE(), char const *const function=TETL_BUILTIN_FUNCTION()) noexcept -> source_location
Definition source_location.hpp:22
constexpr auto column() const noexcept -> etl::uint_least32_t
Definition source_location.hpp:41
constexpr auto function_name() const noexcept -> char const *
Definition source_location.hpp:45
constexpr auto file_name() const noexcept -> char const *
Definition source_location.hpp:43
constexpr source_location() noexcept=default
constexpr auto line() const noexcept -> etl::uint_least32_t
Definition source_location.hpp:39