首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

见见这段代码是否完美

2012-09-06 
看看这段代码是否完美C/C++ codebit(const bit &other) noexcept {}bit(bit &&other) noexcept {// Reset

看看这段代码是否完美

C/C++ code
bit(const bit &other) noexcept {}bit(bit &&other) noexcept {    // Reset source object}auto operator=(const bit &other) noexcept -> bit &{    if (this != &other)    {        bit tmp(other);        std::swap(*this, tmp);    }        return *this;}auto operator=(bit &&other) noexcept -> bit &{    if (this != &other)    {        bit tmp(forward<bit>(other));// 总觉得这里不够好, 为何不能直接 std::swap(*this, forward<bit>(other))?        std::swap(*this, tmp);    }        return *this;}


如果对 C++11 感兴趣, 请加群: 256965276

[解决办法]
本人水平实在有限, 请各路高人指点. 

热点排行