我正在修改别人的(非git)代码.我下载了原版,随后进行了修改,然后跳了一下枪,并将修改后的版本作为我的第一次提交.这是一个错误,我应该添加原始下载的代码作为我的第一次提交.
然后添加侮辱伤害,我添加原始代码作为我的第一次编辑的分支..换句话说,它现在是一个大混乱:(
简单来说,我看起来像下面的蓝图.C5是实际的原始代码,C1,C2-C6是我的逐步修改(C4是多余的).我宁愿让绿色成为我的历史.

任何想法如何修改历史来实现这一目标?
谢谢很多,
狡猾
这里有一个很好的小技巧,允许使用std::unique_ptr不完整的类型。
这是相关代码:
// File: erasedptr.h
#include <memory>
#include <functional>
// type erased deletor (an implementation type using "veneer")
template <typename T>
struct ErasedDeleter : std::function<void(T*)>
{
ErasedDeleter()
: std::function<void(T*)>( [](T * p) {delete p;} )
{}
};
// A unique_ptr typedef
template <typename T>
using ErasedPtr = std::unique_ptr<T, ErasedDeleter<T>>;
// Declare stuff with an incomplete type
struct Foo;
ErasedPtr<Foo> makeFoo();
// File: main.cpp (Foo's definition is not available in this translation unit)
#include "erasedptr.h"
int main() { …Run Code Online (Sandbox Code Playgroud) 采取以下,
template<class T>
struct Foo {
Foo(){}
// a template constructor "generalized" over related types
template<class U>
Foo(Foo<U> const&) {
std::cout << 1;
}
// copy constructor
Foo(Foo const&) {
std::cout << 2;
}
};
Run Code Online (Sandbox Code Playgroud)
及其用户:
void main() {
Foo<int> f1;
Foo<const int> f2(f1); // prints 1
Foo<const int> f3(f2); // prints 2
}
Run Code Online (Sandbox Code Playgroud)
即使没有显式复制构造函数,编译器也会生成一个并使用它f3(f2).
有没有办法强制模板重载?例如,复制构造函数可以是SFINAE吗?这是为了避免代码重复,有趣的是,似乎没有办法使用委托构造函数(从复制构造函数委托给模板).