C++ 如何快速获取一个函数是哪个命名空间里面的?

可以参考:

C++ 如何快速获取一个变量是哪个命名空间里面的?

过程是一样的。

/// @file main.cc
/// @author zhaolu
/// @version 1.0
/// @data 2020-03-14

#include <iostream>
#include <string>
#include <algorithm>

namespace zhaolu
{
template<typename T>
class matrix final
{
public:
	explicit matrix(uint32_t size):
		SIZE(size) 
	{
		_data = static_cast<T**>(malloc(SIZE * sizeof(T*)));
		for (uint32_t i = 0; i < SIZE; ++i)
		{
			_data[i] = new T[SIZE];
		}
	}

	inline const uint32_t size() const
	{
		return SIZE;
	}

	T* operator[](uint32_t index) const
	{
		return _data[index];
	}

	~matrix()
	{
		for (uint32_t i = 0; i < SIZE; ++i)
		{
			delete[] _data[i];
		}
		free(_data);
	}

private:
	const uint32_t SIZE;
	T** _data;
};
}

using namespace std;
using namespace zhaolu;

int fun(string s,matrix<int> m)
{
	m.size();
	return 0;
}

int main()
{
	int a[5]={1,2,3,4,5};
	sort(a,a+5);
	return 0;
}

编译:

gcc -lstdc++ -std=c++11 main.cc -o main.o

解析如下:

:objdump -t main.o | awk '{print $5}' | c++filt 

64-bit


void std::__1::sort<int*>(int*, int*)
void std::__1::sort<int*, std::__1::__less<int, int> >(int*, int*, std::__1::__less<int, int>)
__dyld_private
fun(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, zhaolu::matrix<int>)
zhaolu::matrix<int>::size() const
__mh_execute_header
_main

稍微有点复杂。

还是很麻烦。

简单的是完了,那复杂的咋办。。。

能不能自动替换呢,写个脚本???

发布了140 篇原创文章 · 获赞 6 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/LU_ZHAO/article/details/104865693