xtd 0.2.0
source_location_invoked_directly.cpp

Shows how to use xtd::diagnostics::source_location class.

#include <xtd/io/path>
#include <xtd/console>
#include <xtd/diagnostics/source_location>
using namespace xtd;
using namespace xtd::diagnostics;
using namespace xtd::io;
void print_this_file_name() {
auto location = source_location::current();
console::write_line("File: {}", path::get_file_name(location.file_name()));
}
auto main() -> int {
print_this_file_name();
}
// This code can produce the following output :
//
// File: source_location_invoked_directly.cpp
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
static source_location current(const __xtd_source_location__ &value=__xtd_source_location__::current()) noexcept
Crates a new xtd::diagnostics::source_location object corresponding to the location of the call site.
static xtd::string get_file_name(const xtd::string &path)
Returns the file name and extension of the specified path string.
The xtd::diagnostics namespace provides classes that allow you to interact with system processes,...
Definition assert_dialog_result.hpp:10
The xtd::io namespace contains types that allow reading and writing to files and data streams,...
Definition binary_reader.hpp:17
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8