|
Download cpp/cpp-stackoverflow-001.jsonl from winapiadmin/tinycodinglm: direct link, hf CLI and curl.
- Browser
- Download file 2.82 kB
-
https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/d517dc97f4cfcf6f6f9b7fafc368554f077178b3/cpp/cpp-stackoverflow-001.jsonl
- Command line
-
hf download hf://datasets/winapiadmin/tinycodinglm@d517dc97f4cfcf6f6f9b7fafc368554f077178b3/cpp/cpp-stackoverflow-001.jsonl
-
curl -L -o cpp-stackoverflow-001.jsonl https://huggingface.co/datasets/winapiadmin/tinycodinglm/resolve/d517dc97f4cfcf6f6f9b7fafc368554f077178b3/cpp/cpp-stackoverflow-001.jsonl
2.82 kB
| {"type": "session", "harness": "opencode", "id": "cpp-stackoverflow-001", "name": "Common C++ Stack Overflow patterns"} | |
| {"type": "message", "message": {"role": "system", "content": "You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies."}} | |
| {"type": "message", "message": {"role": "user", "content": "Common C++ patterns from Stack Overflow"}} | |
| {"type": "message", "message": {"role": "assistant", "content": "**Common C++ Stack Overflow Patterns:**\n\n**1. How to split a string by delimiter:**\n```cpp\n#include <sstream>\n#include <vector>\n\nstd::vector<std::string> split(const std::string& s, char delim) {\n std::vector<std::string> result;\n std::istringstream iss(s);\n std::string token;\n while (std::getline(iss, token, delim)) {\n result.push_back(token);\n }\n return result;\n}\n```\n\n**2. How to convert int to string:**\n```cpp\n// C++11+\nstd::string s = std::to_string(42);\n\n// Using ostringstream\nstd::ostringstream oss;\noss << 42;\nstd::string s = oss.str();\n```\n\n**3. How to trim a string:**\n```cpp\nstd::string trim(const std::string& s) {\n auto start = s.find_first_not_of(\" \\t\\n\\r\");\n auto end = s.find_last_not_of(\" \\t\\n\\r\");\n return (start == std::string::npos) ? \"\" : s.substr(start, end - start + 1);\n}\n```\n\n**4. How to check if string contains substring:**\n```cpp\n// C++23\nif (str.contains(\"sub\")) { }\n\n// C++11\nif (str.find(\"sub\") != std::string::npos) { }\n```\n\n**5. How to read entire file to string:**\n```cpp\nstd::ifstream f(\"file.txt\");\nstd::string content((std::istreambuf_iterator<char>(f)),\n std::istreambuf_iterator<char>());\n```\n\n**6. How to create a singleton:**\n```cpp\nclass Singleton {\npublic:\n static Singleton& instance() {\n static Singleton inst;\n return inst;\n }\n Singleton(const Singleton&) = delete;\n Singleton& operator=(const Singleton&) = delete;\nprivate:\n Singleton() = default;\n};\n```\n\n**7. How to implement a thread-safe queue:**\n```cpp\ntemplate<typename T>\nclass ThreadSafeQueue {\n std::queue<T> queue_;\n mutable std::mutex mutex_;\npublic:\n void push(T value) {\n std::lock_guard<std::mutex> lock(mutex_);\n queue_.push(std::move(value));\n }\n bool pop(T& value) {\n std::lock_guard<std::mutex> lock(mutex_);\n if (queue_.empty()) return false;\n value = std::move(queue_.front());\n queue_.pop();\n return true;\n }\n};\n```"}} | |