小编Won*_*Boi的帖子

std :: move used,移动构造函数调用但对象仍然有效

有人可以解释为什么通过std :: move传递给新对象的原始对象之后仍然有效吗?

#include <iostream>

class Class
{

public:
    explicit Class(const double& tt) : m_type(tt)
    {
        std::cout << "defaultish" << std::endl;
    };

    explicit Class(const Class& val) :
        m_type(val.m_type)
    {
        std::cout << "copy" << std::endl;
    };

    explicit Class(Class&& val) :
        m_type(val.m_type)
    {
        m_type = val.m_type;
        std::cout << "move: " << m_type << std::endl;
    };

    void print()
    {
        std::cout << "print: " << m_type << std::endl;
    }

    void set(const double& tt)
    {
        m_type = tt;
    }

private:

    double m_type;    
};

int main …
Run Code Online (Sandbox Code Playgroud)

c++ move rvalue-reference

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

为什么我不能通过管道 npm install 到 sed,同时保留颜色和进度更新?

如果我输入npm i | sed "s/^/ /",输出npm i到标准输出时不会间隔。例如,我得到以下信息:

$ npm i | sed "s/^/    /"
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 
(node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 
fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: 
{"os":"linux","arch":"x64"})
npm WARN [name_removed]@0.0.2 No repository field.
npm WARN [name_removed]@0.0.2 No license field.
Run Code Online (Sandbox Code Playgroud)

代替:

$ npm i | sed "s/^/    /"
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 
    (node_modules/chokidar/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for 
    fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} …
Run Code Online (Sandbox Code Playgroud)

bash sed node.js npm npm-install

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

标签 统计

bash ×1

c++ ×1

move ×1

node.js ×1

npm ×1

npm-install ×1

rvalue-reference ×1

sed ×1