This class implements the source_location specification that will eventually be included in C++20. We make some changes to the specification to support AUTOSAR, but these changes should not change how the code is compiled or used, with the exception that we do not include the column() as this does not seem to be implemented by any compilers yet.
More...
#include <source_location.hpp>
|
static constexpr source_location | current (file_type const current_file=BSL_BUILTIN_FILE, func_type const current_func=BSL_BUILTIN_FUNCTION, line_type const current_line=BSL_BUILTIN_LINE) noexcept |
| Constructs a new source_location object corresponding to the location of the call site. More...
|
|
This class implements the source_location specification that will eventually be included in C++20. We make some changes to the specification to support AUTOSAR, but these changes should not change how the code is compiled or used, with the exception that we do not include the column() as this does not seem to be implemented by any compilers yet.
namespace bsl
{
inline void
example_source_location_overview() noexcept
{
}
}
◆ source_location()
constexpr bsl::source_location::source_location |
( |
| ) |
|
|
inlinenoexcept |
Creates a default constructed source location. By default, a source location's file name is "unknown", the function name is "unknown" and the line location is "-1".
namespace bsl
{
inline void
example_source_location_default_constructor() noexcept
{
}
}
◆ current()
static constexpr source_location bsl::source_location::current |
( |
file_type const |
current_file = BSL_BUILTIN_FILE , |
|
|
func_type const |
current_func = BSL_BUILTIN_FUNCTION , |
|
|
line_type const |
current_line = BSL_BUILTIN_LINE |
|
) |
| |
|
inlinestaticnoexcept |
Constructs a new source_location object corresponding to the location of the call site.
namespace bsl
{
inline void
example_source_location_current() noexcept
{
}
}
- Note
- You should not set the parameters manually. Instead, use the default parameters which will contain the location information provided by the compiler.
-
We DO NOT ensure by contract that the source location contains valid pointers for the file name and function name which means the resulting source_location could return a nullptr for both the file name and function name. Care should be taken to ensure the proper checks are made as needed.
-
Instead of using bsl::source_location::current() to get the current source_location, use bsl::here() which provides a function with less verbosity.
- Parameters
-
current_file | defaults to the current file name |
current_func | defaults to the current function name |
current_line | defaults to the current line location |
- Returns
- returns a new source_location object corresponding to the location of the call site of current().
◆ file_name()
constexpr file_type bsl::source_location::file_name |
( |
| ) |
const |
|
inlinenoexcept |
Returns the file name associated with the bsl::source_location.
namespace bsl
{
inline void
example_source_location_file_name() noexcept
{
}
}
- Returns
- returns the file name associated with the
◆ function_name()
constexpr func_type bsl::source_location::function_name |
( |
| ) |
const |
|
inlinenoexcept |
Returns the function name associated with the bsl::source_location.
namespace bsl
{
inline void
example_source_location_function_name() noexcept
{
}
}
- Returns
- returns the function name associated with the
◆ line()
constexpr line_type bsl::source_location::line |
( |
| ) |
const |
|
inlinenoexcept |
Returns the line location associated with the bsl::source_location.
namespace bsl
{
inline void
example_source_location_line() noexcept
{
}
}
- Returns
- returns the line location associated with the
◆ operator<<()
template<typename T >
constexpr out< T > operator<< |
( |
out< T > const |
o, |
|
|
source_location const & |
sloc |
|
) |
| |
|
related |
Outputs the provided bsl::source_location to the provided output type.
- Template Parameters
-
T | the type of outputter provided |
- Parameters
-
- Returns
- return o
The documentation for this class was generated from the following file: