今天我刚刚下载了"dotnet-dev-osx-x64.1.0.0-preview1-002702.pkg"并安装了它.之后我在终端上尝试了"dotnet"命令,没有打印出来.
我也试过Spotlight搜索,似乎一无所获.
这个包装在哪里安装?
结构C定义了几个静态const成员,如下所示:
代码如下:
#include<stdio.h>
struct C{
static int i;
static const int j=1;
static constexpr double d=1;
static const double d1=1.0;
};
int main(){
return 0;
}
Run Code Online (Sandbox Code Playgroud)
编译将导致错误:
$g++ testStatic.cpp -std=c++11
testStatic.cpp:6:25: error: in-class initializer for static data member of
type 'const double' requires 'constexpr' specifier
[-Wstatic-float-init]
static const double d1=1.0;
^ ~~~
testStatic.cpp:6:5: note: add 'constexpr'
static const double d1=1.0;
^
constexpr
1 error generated.
Run Code Online (Sandbox Code Playgroud)
为什么这么奇怪为什么static int可以是const?double应该是constexpr?
为什么我得到如下的输出?
> List.length [1,2,3];;
val it : int = 1
> List.length [1,2,3,4];;
val it : int = 1
Run Code Online (Sandbox Code Playgroud)
我期待得到3和4!我使用不正确的函数调用吗?
http://en.cppreference.com/w/cpp/language/fold的网站举例说明了如何使用折叠概念,它说:
Note
If the expression used as init or as pack has an operator with precedence
below cast at the top level, it can be parenthesed:
template<typename ...Args>
int sum(Args&&... args) {
// return (args + ... + 1 * 2); // Error: operator with precedence below cast
return (args + ... + (1 * 2)); // OK
}
Run Code Online (Sandbox Code Playgroud)
作为一个非英语母语的人,我不退出这句话:
has an operator with precedence below cast at the top level
Run Code Online (Sandbox Code Playgroud)
它实际意味着什么,它的例子,它表明了什么?你能帮忙解释一下吗?
非常感谢.
使用make时,我可以指定'make -B'来强制重建.
但是如何用scons指定它,强制重建'all'或强制重建特定文件夹?谢谢.
我有一个像这样的简单程序:
template<class T1,class T2>
decltype(auto) Add(T1&& t1,T2&& t2)
{
return t1+t2
}
int main(){
int i=Add(1,2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
它使用 clang++ -std=c++14 进行编译。我发现我可以消除“decltype”关键字,如下所示:
template<class T1,class T2>
auto Add(T1&& t1,T2&& t2)
{
return t1+t2;
}
int main(){
int i=Add(1,2);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
不过,没问题。所以我的问题是,在不同的场景中,“decltype(auto)”和“auto”何时有所不同?我只是猜测“decltype(auto)”是为“auto”无法工作时更复杂的情况而设计的?但具体是什么,请指教。
多谢。
我有以下程序:
struct A{ int i; };
int main()
{
const int i = 0;
auto ai = i;
ai = 2; // OK
const A buf[2];
for(auto& a : buf)
{
a.i = 1; // error!
}
std::cout << buf[0].i << buf[1].i << std::endl;
}
Run Code Online (Sandbox Code Playgroud)
第一个auto ai = i;没有问题,似乎auto没有检索c/v限定符,因为ai可以修改但for循环失败编译为 - 错误:A::i在只读对象中分配成员
我知道这auto不会检索&功能,我的问题是:auto在我的情况下检索c/v限定符吗?我的测试程序似乎给出了相互矛盾的提示.
语言标准说:
[注意:第5节定义了语法,评估顺序和表达式的含义.58表达式是指定计算的运算符和操作数的序列.表达式可能会导致值,并可能导致副作用. - 结束说明]
我的代码如下:
int i=1;
A obj;
Run Code Online (Sandbox Code Playgroud)
那么,上面的两个陈述都算作"表达式"吗?
stackoverflow上的一些人说"int i = 1;" 不是表达.这对我来说很奇怪.
(1)初始化是一种"计算",对吧?所以它应该被视为"表达"?
(2)对象; //调用一个ctor.ctor是一种计算,所以它应该被视为"表达"?
sudo apt-get install libuv
$ sudo apt-get install libuv
[sudo] username ...
It fails to find package and install.
Run Code Online (Sandbox Code Playgroud)
libuv是否包含在其他一些软件包中?
我发现它们是不同的,语言标准规定了每个语句应该检索哪种类型(变量和表达式之间的差异)。但我真的很想知道为什么这两种类型应该不同?
#include<stdio.h>
int x=0;
decltype((x)) y=x;
int main()
{
y=2;
printf("%d,",x);
decltype((1+2))&z=x;//OK (1+2) is an express, but why decltype should differ?
z=3;
printf("%d\n",x);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
运行结果是'2,3'
那么为什么decltype((int))是int&设计,这里C++语言设计的考虑是什么?任何需要这种设计的语法一致性?(我不想得到“这是设计使然”)
谢谢你的解释。