GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
std::experimental::source_location(3) C++ Standard Libary std::experimental::source_location(3)

std::experimental::source_location - std::experimental::source_location


Defined in header <experimental/source_location>
struct source_location; (library fundamentals TS v2)


The source_location class represents certain information about the source code, such
as file names, line numbers, and function names. Previously, functions that desire
to obtain this information about the call site (for logging, testing, or debugging
purposes) must use macros so that predefined macros like __LINE__ and __FILE__ are
expanded in the context of the caller. The source_location class provides a better
alternative.


Creation
constructs a new source_location with implementation-defined
constructor values
(public member function)
current constructs a new source_location
[static] (public static member function)
Other special member functions
destructor destructs a source_location
(implicitly declared) (public member function)
operator= Implicitly declared copy/move assignment operators
(implicitly declared) (public member function)
Field access
line return the line number represented by this object
(public member function)
column return the column number represented by this object
(public member function)
file_name return the file name represented by this object
(public member function)
return the name of the function represented by this object, if
function_name any
(public member function)

// Run this code


#include <iostream>
#include <string_view>
#include <experimental/source_location>


void log(const std::string_view& message, const std::experimental::source_location& location = std::experimental::source_location::current())
{
std::cout << "info:"
<< location.file_name() << ":"
<< location.line() << " "
<< message << '\n';
}


int main()
{
log("Hello world!");
}


info:main.cpp:15 Hello world!

2022.07.31 http://cppreference.com

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.