好吧,我有一个麻烦,因为有些星期以来我无法修复.我使用git(在github上)来存储我的项目.最近我添加了一些新文件没有问题,但是,当我使用"git push"时,我有一个超时错误.
我使用Ubuntu 12.04,ssh(默认)和https.
所以,我决定制作depo(git clone)的新副本.在此之后,我修改现有文件,提交并推送它...成功!
所以,我添加其他(在新副本中),提交它们并推送它们.问题再次出现:无法推送这是控制台输出:
time git push
Counting objects: 13, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (11/11), done.
Writing objects: 100% (11/11), 16.61 KiB, done.
Total 11 (delta 2), reused 0 (delta 0)
^C
real 7m59.383s
user 0m0.008s
sys 0m0.004s
Run Code Online (Sandbox Code Playgroud)
我真的不明白我在这里做错了什么.我在其他depo,同样的问题,但我的合作者没有任何麻烦.
我删除git,并重新安装它没有任何变化.
如果您有任何想法可以解决这个问题.
git remote -v
origin git@github.com:Krozark/projet_compilation.git (fetch)
origin git@github.com:Krozark/projet_compilation.git (push)
Run Code Online (Sandbox Code Playgroud)
sudo ifconfig [wlan0] mtu 1460 (lower than 1500)
Run Code Online (Sandbox Code Playgroud) 我尝试创建一个类来轻松管理资源(ResourceManager).
为此,我使用C++ 11模板.
这是我做的:
template<class K,class T>
class ResourceManager
{
public:
ResourceManager();
~ResourceManager();
/* code */
void clear();
private :
std::unordered_map<K,T> resource;
template <bool b>
void clear();
};
Run Code Online (Sandbox Code Playgroud)
template<class K,class T>
void ResourceManager<K,T>::clear()
{
clear<std::is_pointer<T>::value>();
};
template<class K,class T>
template<bool b>
void ResourceManager<K,T>::clear<b>()
{
for(auto& x:resource)
delete x.second;
resource.clear();
}
template<class K,class T>
template<>
void ResourceManager<K,T>::clear<false>()
{
resource.clear();
}
Run Code Online (Sandbox Code Playgroud)
简而言之,如果T
是指针(自动删除),我会尝试使用不同的comportement .
我尝试使用std::enable_if
,但我不明白它是如何运作的,如果这是正确的方法.
如果有人能帮助我......
代码可以在这里找到:https://github.com/Krozark/ResourceManager
我尝试使用线程调用对象的成员函数.
如果函数没有可变参数模板(Args ... args),没问题,它可以工作:
考虑两个类:
GeneticEngine
template <class T>
class GeneticEngine
{
template <typename ... Args>
T* run_while(bool (*f)(const T&),const int size_enf,Args& ... args)
{
std::thread(&GeneticThread<T>::func,islands[0],f,size_enf);
/* Some code */
return /* ... */
}
private:
GeneticThread<T>** islands;
}
Run Code Online (Sandbox Code Playgroud)
GeneticThread
template <class T>
class GeneticThread
{
void func(bool (*f)(const T&),const int size_enf)
{
/* Some code */
};
}
Run Code Online (Sandbox Code Playgroud)
有了它,没关系.
现在,我将一个可变参数模板添加到相同的函数中:
GeneticEngine
template <class T>
class GeneticEngine
{
template <typename ... Args>
T* run_while(bool (*f)(const T&,Args& ...),const int size_enf,Args& ... …
Run Code Online (Sandbox Code Playgroud) 我试着理解std :: enable_shared_from_t这个类的行为,但我无法理解它.所以我写了一个简单的程序来测试不同的情况.
有人可以解释一下下面代码的行为,因为我无法解释观察到的结果.
谢谢你的帮助.
#include <iostream>
#include <memory>
struct C : std::enable_shared_from_this<C> { };
int main () {
{//test 1
std::shared_ptr<C> foo, bar;
foo = std::make_shared<C>();
bar = foo->shared_from_this(); //ok
std::cout<<"shared_ptr : ok"<<std::endl;
}
{//test 2
std::shared_ptr<C> foo = std::shared_ptr<C>(new C);
std::shared_ptr<C> bar;
bar = foo->shared_from_this(); //ok
std::cout<<"shared_ptr + New : ok"<<std::endl;
}
{//test 3
C* foo = new C;
std::shared_ptr<C> bar;
bar = foo->shared_from_this(); //throw std::bad_weak_ptr
std::cout<<"New : ok"<<std::endl;
}
{//test 4 (should make a invalid …
Run Code Online (Sandbox Code Playgroud) 在我的一个项目中,我初始化了一个const std :: string&with const char(在编译时知道),打印结果是......令人惊讶.
我在Ubuntu 12.04x32上使用gcc版本4.6.3(Ubuntu/Linaro 4.6.3-1ubuntu5)
例:
#include <string>
#include <iostream>
using namespace std;
class A
{
public:
A() : str("test"){};
const string& str;
};
int main(int argc,char* argv[])
{
A a;
cout<<a.str<<endl;
return 0;
};
Run Code Online (Sandbox Code Playgroud)
所以,正常情况下,它会显示"测试"但是,这是我输出的prt:
testP?????utf8)????lower_case_table_names?xW?xW? ?? ????127.0.0.1utf8W?Y127.0.0.1 via TCP/IP127.0.0.1
?5.5.31-0ubuntu0.12.04.1rootW?rootW?1????metadata_use_info_schema!P?XP?? VARa?pW?P4:????SHOW SESSION VARIABLES LIKE 'lower_case_table_names'`(???TCP/IP (3)@!K!K!?
.....
<charset name="gb2312">
<family>Simplified Chinese</family>
<description>GB2312 Simplified Chinese</description>
<alias>chinese</alias>
<alias>iso-ir-58</alias>
<collation name="gb2312_chinese_ci" id="24" order="Chinese">
<flag>primary</flag>
<flag>compiled</flag>
</collation>
<collation name="gb2312_bin" id="86">
<flag>binary</flag>
<flag>compiled</flag>
</collation>
</charset>
Run Code Online (Sandbox Code Playgroud)
输出连续1000行.
所以我的问题很简单:为什么?(我尝试在"测试"结束时添加\ 0,但没有更改)