std

    10热度

    3回答

    通常当我做一个std :: find时,我会把一个谓词作为第三个参数,但是这次我想我会以不同的方式做它,不明白为什么它不起作用。 #include <iostream> #include <vector> #include <algorithm> struct RenderJob { RenderJob() {}; int renderJob_ID; boo

    0热度

    1回答

    struct A { }; struct B : A { virtual ~B() {} }; template<typename BASE, typename EXTENDED> void ASSERT_BASE_EXTENDED() { static_assert(static_cast<BASE*>((EXTENDED*)256)==(BASE*)256,

    0热度

    1回答

    class Function { public: std::string Name; void call(std::string x); Function(std::string Nam) { Name = Nam; } }; std::vector<Function> funcs; void Load_FuncLib(

    0热度

    1回答

    我一直在想办法让我的类方法采用任意数量的回调函数,运行所有这些函数,然后存储输出。我认为这是有效的,但有没有一种方法可以做到这一点,我不必让用户将所有的回调函数都包含到向量中?这也只是感觉混乱。随意提及其他不理想的事情。 #include <iostream> #include <functional> #include <vector> class MyObj{ public:

    4热度

    1回答

    经过12年的间歇后回到C++开发。我使用JetBrains的CLion软件,这非常棒,因为它提供了关于我的班级设计中可能出现的问题的大量输入。我在课堂上的构造函数throw statement中得到的警告之一是:Thrown exception type is not nothrow copy constructible。以下是生成此警告的代码示例: #include <exception> #

    6热度

    2回答

    有关于如何使用std::unique从一个字符串中删除连续的空格上cppreference一个例子独特的例子: std::string s = "wanna go to space?"; auto end = std::unique(s.begin(), s.end(), [](char l, char r){ return std::isspace(l) && std::isspa

    0热度

    2回答

    我的C++代码的以下代码片段出现编译错误。 struct Power{ int power; int age; int operator-(const Power& p1) { return this->power - p1.power; } }; int main() { Power p1; p1.power

    0热度

    1回答

    预选赛由于我post从昨天开始认真评选,在这里再次,只有最小的例子,我的问题。 #include <set> #include <algorithm> using namespace std; class dummy { public: dummy(int x) : test(x) {} bool operator()(const int &

    1热度

    2回答

    矢量如果我有std::unique_ptr的std::vector和调整其大小,并希望通过指数来添加元素,什么是使用operator=增加他们的最好方法是什么? std::vector<std::unique_ptr<item>> _v; _v.resize(100); // is it safe to use the assignment operator? _v[20] = new it

    1热度

    1回答

    我需要递归搜索文件到一个目录及其子目录中,但我想从搜索中排除一个路径(及其文件和子目录)。 我正在使用std::experimental::filesystem::recursive_directory_iterator和pop()修饰符,但它不起作用。我错在哪里? void search(const char* pathToSearch,const char* pathToExclude){