与此问题略相关,我想在shell脚本中使用一个临时分支。
有点像:
cd $(git rev-parse --show-toplevel) &&
git subtree split --prefix=some_subfolder -b temp &&
git push my_remote temp:publication_branch -f
Run Code Online (Sandbox Code Playgroud)
现在,我不确定如果分支temp已经存在,该怎么办,无论如何,我都不希望结果my_remote/publication_branch依赖于此。而且我也不想修改分支temp(假设我有不相关的东西)。充其量,我也会在最后进行清理
cd $(git rev-parse --show-toplevel) &&
git subtree split --prefix=some_subfolder -b temp &&
git push my_remote temp:publication_branch -f
git branch -D temp
Run Code Online (Sandbox Code Playgroud)
因此,我正在寻找一种创建尚不存在的临时分支名称的方法,类似于mktemp?是否有可以创建临时分支名称的git命令?
我想知道 zsh 使用哪个函数来完成命令的制表符。\n对于许多命令(make、ls、cd\xe2\x80\xa6),我显然可以猜测_<COMMANDNAME>,但实际上我可能已经用 覆盖了此设置compdef _mycd cd。
我想知道这个问题的原因有两个:
\n\n_nice,但我可能不依赖shift; CURRENT--; _normal)我正在尝试使用范围 v3 实现屏蔽范围视图。不知何故,我最终陷入了我实施
ranges::view::masker(datarange, mask)
Run Code Online (Sandbox Code Playgroud)
有效,但管道版本
ranges::view::all(datarange) | ranges::view::masker(mask)
Run Code Online (Sandbox Code Playgroud)
没有,虽然有了operators内部结构,面具正确到达。(我将我的实现masker放入ranges::view命名空间,尽管它不是范围 v3 的一部分)。
我的测试程序比较琐碎,创建了一些小部件和一个无意义的掩码
class Widget
{
private:
int m_int{0};
public:
Widget() {}
Widget( int i ) : m_int( i ) {}
int the_int() const { return m_int; }
};
inline std::ostream& operator<<( std::ostream& str, const Widget& obj )
{
str << '\t' << obj.the_int();
return str;
}
int main()
{
std::vector<Widget> widgets;
std::vector<bool> mask;
for ( auto i : ranges::view::indices( 24 ) ) { …Run Code Online (Sandbox Code Playgroud) 在以下代码段中,A由于复制省略,没有移动和复制
struct A;
A function1();
A function2();
int main(int argc, char**) {
if (argc > 3) {
A a = function1();
} else {
A a = function2();
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这很好,但是a在 if 块之外无法访问。当在a外面宣布时,然后移动发生
struct A;
A function1();
A function2();
int main(int argc, char**) {
A a;
if (argc > 3) {
a = function1();
} else {
a = function2();
}
return 0;
}
Run Code Online (Sandbox Code Playgroud)
当它应该在调用站点的 if 块中发生到 if 范围之外的变量时,从复制省略中获利的推荐方法是什么?
我正在尝试使用python为TTree(ROOT对象)创建一个过滤器pyROOT.我从TTree获得了几个分支的信息,其中一些分支是C++类型的vector<int>,vector<float>或者vector<string>是.
为了将信息传递到新树,我需要从旧树访问它,我需要将向量等的地址传递给树,然后填充树.为此,我需要访问这样一个新向量的地址.这在C++中非常简单,但在查看Cython和boost之后,我无法解决这个问题.最终我想要像:
cppintvectorinpython = getcppintvector()
oldtree.setbranchaddress(branchname,cppintvectorinpython)
Run Code Online (Sandbox Code Playgroud)
这可能吗?
我正在努力解决这个问题
使用标准的for-in循环将所有小于或等于100的奇数加到oddNumbers数组中
我尝试了以下方法:
var oddNumbers = [Int]()
var numbt = 0
for newNumt in 0..<100 {
var newNumt = numbt + 1; numbt += 2; oddNumbers.append(newNumt)
}
print(oddNumbers)
Run Code Online (Sandbox Code Playgroud)
这导致:
1,3,5,7,9,... 199
我的问题是:虽然我指定0到<100之间的范围,为什么打印数字大于100?
以下代码包含一个fold表达式,afaiu是c ++ 17的一个功能:
template <typename... T> static bool variable_length_or(const T ... v) {
return (v || ...);
}
bool foo () {
return variable_length_or(true, false, true, false);
}
Run Code Online (Sandbox Code Playgroud)
我发现奇怪的是,在使用-std=c++14(builder-explorer)进行构建时,g ++和clang ++似乎都很好用。他们确实会发出警告:
<source>:2:16: warning: pack fold expression is a C++17 extension [-Wc++17-extensions]
return (v || ...);
Run Code Online (Sandbox Code Playgroud)
这在某种程度上表明我正在写的东西在c ++ 17之前还不行,但是编译成功了,并且代码似乎在做应该做的事情。我期望编译会失败。
关于为什么编译器接受我的折叠表达式的任何解释?
我正在处理一个类,该类在没有外部声明的情况下在类中定义了友元函数
namespace our_namespace {
template <typename T>
struct our_container {
friend our_container set_union(our_container const &, our_container const &) {
// meaningless for the example here, just a valid definition
// no valid semantics
return our_container{};
}
};
} // namespace our_namespace
Run Code Online (Sandbox Code Playgroud)
正如所讨论的(例如此处或此处),函数set_union不在our_namespace命名空间中,但可以通过参数依赖查找找到:
auto foo(std::vector<our_namespace::our_container<float>> in) {
// works:
return set_union(in[0], in[1]);
}
Run Code Online (Sandbox Code Playgroud)
但是我注意到,调试标志中 set_union似乎是在our_namespace命名空间中
mov rdi, qword ptr [rbp - 40] # 8-byte Reload
mov rsi, rax
call …Run Code Online (Sandbox Code Playgroud) I deal with a class that is meant to be iterable in range based for loops, so it defines an iterator class, begin- and end-method. Now in the example I'm working on, these three are templated (I have this minimal example, where the template parameter isn't really meaningful but just has templated begin and end):
#include <cstddef>
#include <tuple>
#include <vector>
struct Iterable {
using Widget = std::tuple<int, float>;
template <typename access_type>
struct Iterator {
Iterable* m_iterable;
std::size_t m_pos;
bool …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 Linux 上安装 ROOT CERN 软件包,使用 Ubuntu 18.04,每当我进入先决条件下载时,使用以下命令:
sudo apt-get install dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev python openssl-dev
Run Code Online (Sandbox Code Playgroud)
我得到以下输出:
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package openssl-dev
Run Code Online (Sandbox Code Playgroud)
我已尝试按照此线程中的建议配置我的存储库来纠正此问题,但问题仍然存在。
想知道如何解决这个问题。谢谢你。
编辑:
sudo apt update命令的完整输出是:
Hit:1 http://us.archive.ubuntu.com/ubuntu bionic InRelease
Hit:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu bionic-updates InRelease
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
Run Code Online (Sandbox Code Playgroud)
我也尝试安装 libssl-dev …
我试图用这个算法找到素根:
std::vector<unsigned long long> Keyexchange::primroot(unsigned long long val) {
std::vector<unsigned long long> res;
for (unsigned long long i = 2; i<val - 1; i++) {
unsigned long long start = 1;
bool flag = 1;
for (unsigned long long j = 0; j<val / 2; j++) {
start = (start * i) % val;
if (start % val == 1) {
flag = 0;
break;
}
}
if (flag) {
res.push_back(i);
}
}
return res;
}
Run Code Online (Sandbox Code Playgroud)
它工作得很好,但非常慢.我想计算像1073741789这样的大数字的原始根.如果有可能设置范围,那将是最好的,因为我现在正在计算整个数组.
因此,我正在寻找一种方法[代码snipet会很棒]从这个给定的数字产生大约100.000个最大的原始根.
我知道Eulerscheφ函数的速度要快得多,但我不知道如何实现它.
非常感谢.
我正在使用 ROOT Cern 来求解多变量非线性方程组。对于某些问题,我有 4 个函数和 4 个变量。然而,对于其他人,我需要 20 个函数和 20 个变量。我使用一个名为“WrappedParamFunction”的类来包装函数,然后将包装的函数添加到“GSLMultiRootFinder”来解决它们。该函数是这样包装的:
ROOT::Math::WrappedParamFunction<> g0(&f0, "number of variables", "number of parameters");
Run Code Online (Sandbox Code Playgroud)
因此,我需要在我的void main(){}代码部分之前声明 f0...fi 函数。我以这种方式声明函数:
double f0(const double *x, const double *par){return -par[0]+y[0]*par[1];}
double f1(const double *x, const double *par){return -par[1]+y[1]*par[2];}
.
.
Run Code Online (Sandbox Code Playgroud)
有没有办法在循环内创建这些函数并将它们堆叠在数组中?像这样的东西:
double (*f[20])(const double *x, const double *par);
for(int i=0;i<20;i++){
f[i]= -par[i]+x[i]*par[i+1];
}
Run Code Online (Sandbox Code Playgroud)
这样稍后我就可以用这种方式包装函数:
ROOT::Math::WrappedParamFunction<> g0(f[0], "number of variables", "number of parameters");
Run Code Online (Sandbox Code Playgroud)