小编Ray*_*ery的帖子

概念和模板约束之间有什么区别?

我想知道C++完整概念提议和模板约束之间的语义差异(例如,Dlang中出现的约束或C++ 1y的新概念 - 精简提议).

什么是能够比模板约束做的完整概念不能做到的?

c++ d c++11 c++-concepts

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

ifsteam的move构造函数是否被隐式删除?

我有以下简单的类:

class Source
{
public:
    Source() = default;
    Source(Source const&) = delete;
    Source(Source&&) = default;

    explicit Source(std::string const& fileName)
     : inputStream(fileName), path_(fileName)
    {}

    ~Source() = default;

    auto path() const -> std::string
    {
        return this->path_;
    }

    std::ifstream inputStream;
private:
    std::string path_;
};

auto main(int argc, char* argv[]) -> int
{
    Source source(Source("test.txt"));
    cout << source.path() << "\n";

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

根据cppreference ifstream有一个move构造函数,但是当我尝试编译时MinGW 4.7.2,我得到以下错误:

..\src\main.cpp:32:46:错误:使用已删除的函数'cy :: Source :: Source(cy :: Source &&)'在..\src\main.cpp中包含的文件中:10:0 :source.hpp:28:5:注意:'cy :: Source :: …

c++ gcc c++11

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

为什么struct标签不是C中的类型名?

我对C中这种行为的动机感到好奇.是故意还是意外?

struct tpoint // tpoint is not a type name
{
    int x, y;
};

typedef struct tpoint Point; // point is a type name.
Run Code Online (Sandbox Code Playgroud)

我想知道为什么Ritchie或标准委员会选择了这种行为.

c

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

标签 统计

c++ ×2

c++11 ×2

c ×1

c++-concepts ×1

d ×1

gcc ×1