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::function_name(3) C++ Standard Libary std::experimental::source_location::function_name(3)

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


constexpr const char* function_name() const noexcept; (library fundamentals TS v2)


Returns the name of the function associated with the position represented by this
object, if any.


(none)


If this object represents a position in a body of a function, returns an
implementation-defined null-terminated byte string corresponding to the name of the
function.


Otherwise, an empty string is returned.


The following example shows how it is possible to use the
std::source_location::function_name() to print a name of a function, constructor,
destructor, or overloaded operator().

// Run this code


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


inline void function_name(
const std::string_view signature = "()",
const std::experimental::source_location& location
= std::experimental::source_location::current())
{
std::cout
<< location.function_name() // <- name of the caller!
<< signature
<< '\n';
}


void foo() { function_name(); }


struct S {
S() { function_name(); }
S(int) { function_name("(int)"); }
S& operator=(S const&) { function_name("(const S&)"); return *this; }
S& operator=(S&&) { function_name("(S&&)"); return *this; }
~S() { function_name(); }
};


int main()
{
foo();
S p;
S q{42};
p = q;
p = std::move(q);
}


foo()
S()
S(int)
operator=(const S&)
operator=(S&&)
~S()
~S()


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)

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.