Commit cde12ea0 authored by Ingo Lütkebohle's avatar Ingo Lütkebohle

Merge branch 'get-symbol-support-capture-lambdas' into 'master'

Add get_symbol overload as fallback for lambdas with capture

See merge request !100
parents d2369641 1eff1fb1
Pipeline #88671517 failed with stage
in 9 minutes and 37 seconds
......@@ -38,4 +38,11 @@ const char * get_symbol(std::function<T(U...)> f)
return _demangle_symbol(f.target_type().name());
}
// Fallback meant for lambdas with captures
template<typename L>
const char * get_symbol(L && l)
{
return _demangle_symbol(typeid(l).name());
}
#endif // TRACETOOLS__UTILS_HPP_
......@@ -57,6 +57,25 @@ TEST(TestUtils, valid_symbol_lambda) {
"invalid symbol";
}
/*
Testing symbol resolution lambdas with capture.
*/
TEST(TestUtils, valid_symbol_lambda_capture) {
int num = 1;
auto l = [ = ]() {return num + 1;};
EXPECT_STREQ(
get_symbol(l),
"TestUtils_valid_symbol_lambda_capture_Test::TestBody()::{lambda()#1}") <<
"invalid symbol";
auto m = [&](int other_num) {return num + other_num;};
EXPECT_STREQ(
get_symbol(m),
"TestUtils_valid_symbol_lambda_capture_Test::TestBody()::{lambda(int)#2}") <<
"invalid symbol";
}
/*
Testing symbol resolution for std::function object created from std::bind.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment