相关疑难解决方法(0)

如何在Web上2个文件夹中的所有文件之间进行差异?

所以我想将此文件夹 http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ 进行比较http://svn.boost.org/svn/boost/sandbox/boost/extension/.我希望得到一个diff文件.这些文件夹是在svn控制下,但我更喜欢git样式的diff文件(如此处所示)我试过,git diff但它似乎不适用于web文件夹.那么如何在Linux上使用一个命令做同样的事情呢?

更新: 所以我们得到了一个很好的答案.但它的工作原理很奇怪 - 在我看来它显示所有文件(相同的文件)都用相同的内容替换了所有的内容(虽然我确信只有3-4条代码行被改变了)...

更新2: 为了实现我真正需要的东西(在Linux上使用git样式,只有真正改变的行的dif文件):

$ svn export http://cloudobserver.googlecode.com/svn/branches/v0.4/Boost.Extension.Tutorial/libs/boost/extension/ repos2 --native-eol CRLF
$ svn export http://svn.boost.org/svn/boost/sandbox/boost/extension/ repos --native-eol CRLF
$ git diff repos repos2 > fileWithReadableDiff.diff
Run Code Online (Sandbox Code Playgroud)

linux svn git diff file

75
推荐指数
1
解决办法
10万
查看次数

如何强制gcc链接库中未引用的静态C++对象

我正在使用可以构建为共享库或静态库的C++库.该库使用工厂技术,其中静态对象在程序启动时自行注册并创建静态对象.

只要使用共享库,这样就可以正常工作.当使用静态版本时,没有任何静态对象被包含在最终程序中(因为它们没有被直接引用),因此它们的功能不可用.

有没有办法强制gcc在链接时包含库中的所有静态对象?

该库是开源的,我可以修改它,如果这有帮助.

c++ linux gcc static-linking static-initialization

24
推荐指数
1
解决办法
1万
查看次数

是否有一个C++ type_info的可移植包装器,它标准化了类型名称字符串格式?

输出的格式type_info::name()是特定于实现的.

namespace N { struct A; }

const N::A *a;

typeid(a).name(); // returns e.g. "const struct N::A" but compiler-specific
Run Code Online (Sandbox Code Playgroud)

是否有人编写了一个包装器,它返回可靠,可预测的类型信息,这些信息在编译器中是相同的.多个模板化函数将允许用户获取有关类型的特定信息.所以我可以使用:

MyTypeInfo::name(a); // returns "const struct N::A *"
MyTypeInfo::base(a); // returns "A"
MyTypeInfo::pointer(a); // returns "*"
MyTypeInfo::nameSpace(a); // returns "N"
MyTypeInfo::cv(a); // returns "const"
Run Code Online (Sandbox Code Playgroud)

这些函数只是示例,对C++类型系统有更好了解的人可能会设计出更好的API.我感兴趣的那个base().如果禁用RTTI或检测到不支持的编译器,则所有函数都会引发异常.

这似乎是Boost可能实现的那种东西,但我无法在任何地方找到它.是否有便携式库可以做到这一点?

c++ boost types typeid typeinfo

21
推荐指数
1
解决办法
1181
查看次数

boost :: any的访客模式

我找到了这个https://gist.github.com/2945472,但我需要一个不依赖于c ++ 11的实现.我尝试将它转换为仅使用boost,但我遇到了一些麻烦.

这是我想出的:

#include <boost/any.hpp>
#include <boost/function.hpp>
#include <boost/bind.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/unordered_map.hpp>

struct type_info_hash {
    std::size_t operator()(std::type_info const & t) const {
        return t.hash_code();
    }
};

struct equal_ref {
    template <typename T> bool operator()(boost::reference_wrapper<T> a,boost::reference_wrapper<T> b) const {
        return a.get() == b.get();
    }
};
struct any_visitor {
    boost::unordered_map<boost::reference_wrapper<std::type_info const>, boost::function<void(boost::any&)>, type_info_hash, equal_ref> fs;

    template <typename T> void insert_visitor(boost::function<void(T)> f) {
        try {
            fs.insert(std::make_pair(boost::ref(typeid(T)), boost::bind(f, boost::any_cast<T>(boost::lambda::_1))));
        } catch (boost::bad_any_cast& e) {
            std::cout << e.what() << std::endl;
        } …
Run Code Online (Sandbox Code Playgroud)

c++ boost visitor-pattern boost-any

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