小编den*_*nis的帖子

减慢gdb重现bug

我的应用程序中有一个计时错误,只有在我使用valgrind时才会发生,因为valgrind会减慢这个过程.

(它实际上是一个boost :: weak_ptr-exception,我无法本地化)

现在我想知道如何用gdb重现bug.我没有看到组合gdb + valgrind的方法.

谢谢.

debugging gdb valgrind exception timing

5
推荐指数
1
解决办法
257
查看次数

c ++ overload:string literal与boost :: function ambiguity

我的问题代码:

#include <string>
#include <boost/function.hpp>

void func (const std::string&) {}
void func (const boost::function<void()>&) {}

int main() {
    func (main); // good
    func ("bad");
    return 0;
}
Run Code Online (Sandbox Code Playgroud)

=>

error: call of overloaded ‘func(const char [4])’ is ambiguous
overload.cpp:4: note: candidates are: void func(const std::string&)
overload.cpp:5: note:                 void func(const boost::function<void ()()>&)
Run Code Online (Sandbox Code Playgroud)

我知道我可以通过显式调用func(string("bad"))来解决这个问题.或者通过提供一个func(const char*),但我想知道是否有一种方法可以保持调用者方面,如示例中所示,并且不会引入更多重载.

也许是boost :: enable_if的东西?谢谢你的任何提示.

c++ string boost overloading function

5
推荐指数
1
解决办法
534
查看次数

标签 统计

boost ×1

c++ ×1

debugging ×1

exception ×1

function ×1

gdb ×1

overloading ×1

string ×1

timing ×1

valgrind ×1