stl

    2热度

    2回答

    的代码是相当简单: #include <vector> int main() { std::vector<int> v; } 然后我构建和Valgrind的运行: g++ test.cc && valgrind ./a.out ==8511== Memcheck, a memory error detector ==8511== Copyright (C) 2002-2013

    7热度

    2回答

    我正在实施一个简单的std::vector。有两种insert功能: template <typename T, typename Allocator> typename Vector<T, Allocator>::iterator Vector<T, Allocator>::insert(const_iterator pos, size_type count, const T& value)

    1热度

    3回答

    不明白什么是wrogn代码,第二个函数定义或者调用main函数中的这个函数? 我认为,但不是很确定,调用问题,导致没有调用代码编译好。编译器的gcc #include <iostream> #include <vector> #include <algorithm> using namespace std; template<class T> void show_element(T

    1热度

    1回答

    我想在同一行中解析宏。 所以我在地图中定义的宏: map<string, string> collection; collection["ComputerName"] = "Train-Alpha"; collection["State"] = "Unloaded"; 宏符号是$(宏名),所以输入行的样子: string line = "Running on $(ComputerName)

    0热度

    1回答

    我目前在QThread内使用std::condition_variable时遇到问题。 当我在QThread::run()方法内调用nofity_one或notify_all时,我的线程崩溃(“线程仍在运行时,QThread:销毁”)。 class ThreadImpl : public QThread { Q_OBJECT public: ThreadImpl(QObj

    2热度

    2回答

    排序我明白了一个谓语从迭代器的输入范围需要的参数并执行操作如预期,但是当我们提供一个二元谓词和一对迭代器,它是如何工作的?容器的元素如何传递给谓词? E.g. std::sort按字母顺序排序默认字符串矢量,但对它们进行排序,根据大小,我们可以通过一个谓语,如: sort(vec.begin(), vec.end(), [](const string &a, const string &b) {

    -1热度

    1回答

    我有一个非模板类的字符串(string.h中): class String { public: static const unsigned int npos; ... }; 而且我在不同的cpp文件初始化( string.cpp): const unsigned int String::npos = static_cast<unsigned int>(-1); 当我

    0热度

    1回答

    我想找到元v的矩阵中的条目[0] [0] = 1体积[0] [1] =与使用lambda函数的向量v的2并找到STL的。 #include <iostream> #include <algorithm> using namespace std; int main() { vector<vector<int>> v(3); v[0].resize(2);

    4热度

    3回答

    我有这个全局函数在我的计划: static bool IsValidType(const CString& cType) { for (auto pType : {"bmp","jpg","jpeg","gif","tif","tiff","png"}) if (cType == CString(pType)) return true; return

    -2热度

    1回答

    最长行的字符我想要做这样的事情: std::ostringstream os; writingSomeDataToStream(os); const size_t width = getNumberOfCharsInLongestLine(os); const auto header = generateHeader("My diagnostic data", width); showTe