读书人

见见这段代码是否完美

发布时间: 2012-09-06 10:37:01 作者: rapoo

看看这段代码是否完美

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

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

读书人网 >C++

热点推荐