我正在编写一个服务来更新超级项目中每个子模块指向的提交.我这样做的天真方式是git fetch在子模块中运行git reset --hard <hash>,然后添加子模块并提交它.
我想跳过这git fetch一步,简单地强制子模块指向给定的哈希以获得更好的性能(跳过获取对象并占用磁盘空间)并处理上游可能不再存在且无论如何都无法获取的提交(如果他们被强制推动破坏了.
在C++ 03中,使用eg std::pow(double_val, 6)比使用快得多std::pow(double_val, 6.0).
在使用C++ 11进行编译时不再是这种情况.从gcc的libstdc ++ - 4.8查看cmath头文件,可以看到显式的pow(double,int)不再存在,这种情况由以下模板处理,该模板将int提升为double:
template<typename _Tp, typename _Up>
inline typename __gnu_cxx::__promote_2<_Tp, _Up>::__type
pow(_Tp __x, _Up __y) {
typedef typename __gnu_cxx::__promote_2<_Tp, _Up>::__type __type;
return std::pow(__type(__x), __type(__y));
}
Run Code Online (Sandbox Code Playgroud)
这种行为是在C++ 11标准中还是未来的libstdc ++实现可以返回到更快的方法?
其次,如果出于标准或实施原因,更快的行为不再可能,那么再次实现它的最便携方式是什么?我power(...)在"ext/numeric"下的gcc stdlibc ++中看到了一个函数,但这被标记为非标准的 SGI(rip)扩展.
鉴于这是从一个静态成员变量初始化的静态成员变量另一个类中,非文字struct ii有时缺省初始化为0 或到333.这取决于编译或链接顺序.伪代码演示:
class StaticClass: // file 'ONE.cpp/.hpp'
static int i = 2
static struct ii { int a = 333 }
class ABC: // file 'abc.cpp'
static int abc_i = StaticClass::i // always 2
static struct abc_ii = StaticClass::ii // sometimes 0, sometimes 333
Run Code Online (Sandbox Code Playgroud)
调用g++ -std=c++11 abc.cpp ONE.cpp && ./a.out结果i = 2 / ii = 0(gcc 4.8.1,与clang ++ 3.7相同; -Wall -Wextra从不抱怨).
但是调用g++ -std=c++11 …
是否有一种自动方法可以在编译期间或编译后将 .ico 文件嵌入到 .exe 中?我只有命令行工具等可用cl.exe,link.exe即我不想通过项目配置设置添加图标来在 Visual Studio 界面中添加图标,而是将其作为构建系统中的单独步骤(从生成图标) png 文件在构建过程中)。
使用 MSVC 19.11 编译以下代码会产生输出
With 32: 0 99 2 With 64: 0 1 2使用 32 位编译器,并在
With 32: 0 1 2 With 64: 0 99 2使用 64 位编译器。
问题是单个元素初始值设定项列表的类型恰好是size_t。这是一个编译器错误(到目前为止我还没有发现它在任何地方报告过),而不是标准不明确的情况(clang 和 gcc 都没有这个问题)?
#include <cstdint>
#include <vector>
#include <iostream>
int main() {
using T = std::uint16_t;
// fixed with uint32 / uint64 on 32 / 64 bit compilers, respectively,
// but not with int32_t / int64_t
{
std::vector<T> s0;
// std::vector<T> s1{ 99u }; // OK
// …Run Code Online (Sandbox Code Playgroud)