小编Hin*_*sum的帖子

我在mac上安装了dot net core,但没有找到"dotnet"命令

今天我刚刚下载了"dotnet-dev-osx-x64.1.0.0-preview1-002702.pkg"并安装了它.之后我在终端上尝试了"dotnet"命令,没有打印出来.

我也试过Spotlight搜索,似乎一无所获.

这个包装在哪里安装?

macos command install

7
推荐指数
2
解决办法
3205
查看次数

C ++和C ++ 11类的静态成员,double应该使用“ constexpr”,而int可以是“ const”,为什么?

结构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?

c++ double static const c++11

7
推荐指数
1
解决办法
764
查看次数

F#List.length总是返回1?

为什么我得到如下的输出?

> 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!我使用不正确的函数调用吗?

f# list

6
推荐指数
1
解决办法
1293
查看次数

C++ 17:"折叠"概念中"具有优先权的运算符"是什么意思?

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)

它实际意味着什么,它的例子,它表明了什么?你能帮忙解释一下吗?

非常感谢.

casting operator-precedence fold operator-keyword c++17

6
推荐指数
1
解决办法
130
查看次数

Scons:如何强制重建?

使用make时,我可以指定'make -B'来强制重建.

但是如何用scons指定它,强制重建'all'或强制重建特定文件夹?谢谢.

linux rebuild makefile scons option

6
推荐指数
1
解决办法
4565
查看次数

C++14:decltype(auto) 和“auto”作为返回类型有什么区别?

我有一个像这样的简单程序:

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”无法工作时更复杂的情况而设计的?但具体是什么,请指教。

多谢。

c++ return decltype auto c++14

6
推荐指数
0
解决办法
252
查看次数

C++ 11:"auto"关键字是否完全检索cv-qualifier?我的矛盾样本

我有以下程序:

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限定符吗?我的测试程序似乎给出了相互矛盾的提示.

c++ const auto c++11

5
推荐指数
1
解决办法
239
查看次数

是C++"声明和初始化"语句,一个表达式?

语言标准说:

[注意:第5节定义了语法,评估顺序和表达式的含义.58表达式是指定计算的运算符和操作数的序列.表达式可能会导致值,并可能导致副作用. - 结束说明]

我的代码如下:

int i=1;
A obj;
Run Code Online (Sandbox Code Playgroud)

那么,上面的两个陈述都算作"表达式"吗?

stackoverflow上的一些人说"int i = 1;" 不是表达.这对我来说很奇怪.

(1)初始化是一种"计算",对吧?所以它应该被视为"表达"?

(2)对象; //调用一个ctor.ctor是一种计算,所以它应该被视为"表达"?

c++ expression initialization declaration

5
推荐指数
1
解决办法
994
查看次数

如何在ubuntu上安装libuv?

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是否包含在其他一些软件包中?

linux ubuntu install apt-get libuv

5
推荐指数
2
解决办法
1万
查看次数

C++11 为什么“decltype(x)”和“decltype((x))”的类型不同?

我发现它们是不同的,语言标准规定了每个语句应该检索哪种类型(变量和表达式之间的差异)。但我真的很想知道为什么这两种类型应该不同?

#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++语言设计的考虑是什么?任何需要这种设计的语法一致性?(我不想得到“这是设计使然”)

谢谢你的解释。

variables types expression decltype c++11

5
推荐指数
1
解决办法
1121
查看次数