tetl 0.1.0
Embedded Template Library
Loading...
Searching...
No Matches
source_location.cpp
// SPDX-License-Identifier: BSL-1.0
#include <stdio.h>
#if defined(__cpp_consteval)
static auto log(etl::string_view const message, etl::source_location const location = etl::source_location::current())
-> void
{
::printf( //
"file: %s(%u:%u) `%s`: %s\n", //
location.file_name(), //
static_cast<unsigned>(location.line()), //
static_cast<unsigned>(location.column()), //
location.function_name(), //
message.data() //
);
}
template <typename T>
static auto fun(T x) -> void
{
log(x);
}
auto main(int /*argc*/, char const** /*argv*/) -> int
{
log("Hello world!");
fun("Hello C++20!");
return 0;
}
#else
auto main() -> int { return 0; }
#endif
basic_string_view< char, etl::char_traits< char > > string_view
Typedef for common character type char
Definition basic_string_view.hpp:704
constexpr auto data() const noexcept -> const_pointer
Returns a pointer to the underlying character array. The pointer is such that the range [data(); data...
Definition basic_string_view.hpp:171
A class representing information about the source code, such as file names, line numbers,...
Definition source_location.hpp:21
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