次の方法で共有


__func__

(C++11)。事前定義の識別子 __func__ は、外側の関数の非修飾かつ非装飾の名前を含む文字列として暗黙的に定義されます。 __func__ は C++ 標準で必須であり、Microsoft 拡張機能ではありません。

構文

__func__

戻り値

関数名を含む文字の NULL で終わる const char 配列を返します。

#include <string>
#include <iostream>

namespace Test
{
    struct Foo
    {
        static void DoSomething(int i, std::string s)
        {
           std::cout << __func__ << std::endl; // Output: DoSomething
        }
    };
}

int main()
{
    Test::Foo::DoSomething(42, "Hello");

    return 0;
}

要件

C++11