From f38d0ce94fbb330180c5646455296433725ca2f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hendrik=20H=C3=BCbner?= <117831077+HendrikHuebner@users.noreply.github.com> Date: Fri, 23 Jan 2026 01:15:06 +0100 Subject: [PATCH] Add c++ quotes --- frontend/static/quotes/code_c++.json | 168 +++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/frontend/static/quotes/code_c++.json b/frontend/static/quotes/code_c++.json index bb70802800c0..482f55719005 100644 --- a/frontend/static/quotes/code_c++.json +++ b/frontend/static/quotes/code_c++.json @@ -192,6 +192,174 @@ "source": "geeksforgeeks - Inheritance in C++", "length": 80, "id": 32 + }, + { + "text": "#include \nint makeVectorSize3() {\n\tstd::vector v{1,2,3};\n\treturn (int)v.size();\n}", + "source": "vector basic example", + "length": 100, + "id": 33 + }, + { + "text": "#include \n#include \nstd::vector setToVector() {\n\tstd::set s{4,1,3};\n\treturn std::vector(s.begin(), s.end());\n}", + "source": "set to vector conversion", + "length": 145, + "id": 34 + }, + { + "text": "#include \n#include \nint countGreater5() {\n\tstd::vector v{1,6,7,2};\n\treturn (int)std::count_if(v.begin(),v.end(),[](int x){return x>5;});\n}", + "source": "count_if with lambda", + "length": 169, + "id": 35 + }, + { + "text": "#include \n#include \nvoid fillWithSeven() {\n\tstd::vector v(5);\n\tstd::fill_n(v.begin(),5,7);\n}", + "source": "std::fill_n usage", + "length": 123, + "id": 36 + }, + { + "text": "#include \n#include \nint sumWithForEach() {\n\tstd::vector v{1,2,3};\n\tint sum=0;\n\tstd::for_each(v.begin(),v.end(),[&](int x){sum+=x;});\n\treturn sum;\n}", + "source": "std::for_each lambda sum", + "length": 182, + "id": 37 + }, + { + "text": "#include \n#include \nint countEvenRanges() {\n\tstd::vector v{1,2,3,4,5,6};\n\tauto evens = std::views::filter(v,[](int x){return x%2==0;});\n\tint count=0;\n\tfor(int x: evens) count++;\n\treturn count;\n}", + "source": "ranges filter even", + "length": 228, + "id": 38 + }, + { + "text": "#include \ntemplate\nT applyTwice(T x,std::function f) {\n\treturn f(f(x));\n}", + "source": "template with std::function", + "length": 108, + "id": 39 + }, + { + "text": "#include \n#include \nstd::vector removeLessThan(int threshold) {\n\tstd::vector v{7,1,5,3};\n\tv.erase(std::remove_if(v.begin(), v.end(),\n\t\t\t\t[&](int n){return n\nstd::vector initVectorRange() {\n\tint arr[] = {10,20,30,40};\n\treturn std::vector(std::begin(arr), std::end(arr));\n}", + "source": "vector range constructor", + "length": 148, + "id": 41 + }, + { + "text": "#include \n#include \nstd::vector fromSetSorted() {\n\tstd::set s{5,2,8};\n\tstd::vector v(s.begin(), s.end());\n\treturn v;\n}", + "source": "set iteration to vector", + "length": 155, + "id": 42 + }, + { + "text": "#include \n#include \nint uniquePtrSwapDemo() {\n\tstd::unique_ptr a = std::make_unique(10);\n\tstd::unique_ptr b = std::make_unique(20);\n\ta.swap(b);\n\treturn *a + *b;\n}", + "source": "unique_ptr swap example", + "length": 211, + "id": 43 + }, + { + "text": "#include \n#include \nint uniquePtrCustomDeleter() {\n\tauto deleter = [](int* p) { delete p; };\n\tstd::unique_ptr up(new int(42), deleter);\n\treturn *up;\n}", + "source": "unique_ptr custom deleter example", + "length": 201, + "id": 44 + }, + { + "text": "#include \n#include \nint uniquePtrGetDemo() {\n\tstd::unique_ptr up(new int(7));\n\tint* raw = up.get();\n\treturn *raw;\n}", + "source": "unique_ptr get example", + "length": 147, + "id": 45 + }, + { + "text": "#include \nstd::shared_ptr makeSharedInt() {\n\treturn std::make_shared(5);\n}", + "source": "shared_ptr make_shared example", + "length": 96, + "id": 46 + }, + { + "text": "#include \nint sharedPtrUseCount() {\n\tauto sp = std::make_shared(3);\n\tauto sp2 = sp;\n\treturn (int)sp.use_count();\n}", + "source": "shared_ptr use_count example", + "length": 135, + "id": 47 + }, + { + "text": "#include \n#include \nint sharedPtrAliasExample() {\n\nauto p = std::make_shared(10);\n\tstd::shared_ptr alias(p, p.get());\n\treturn *alias;\n}", + "source": "shared_ptr alias example", + "length": 172, + "id": 48 + }, + { + "text": "#include \n#include \nbool hasValueFive() {\n\tstd::vector v{1,2,5,6};\n\treturn std::find(v.begin(), v.end(), 5) != v.end();\n}", + "source": "std::find example", + "length": 152, + "id": 49 + }, + { + "text": "#include \n#include \nint countLessThan3() {\n\tstd::vector v{4,1,2,3};\n\treturn (int)std::count_if(v.begin(), v.end(), [](int n){return n<3;});\n}", + "source": "std::count_if example", + "length": 172, + "id": 50 + }, + { + "text": "#include \n#include \nint accumulateSum() {\n\tstd::vector v{1,2,3,4};\n\treturn std::accumulate(v.begin(), v.end(), 0);\n}", + "source": "std::accumulate example", + "length": 145, + "id": 51 + }, + { + "text": "#include \n#include \nint iteratorDistance() {\n\tstd::vector v{1,2,3,4};\n\treturn (int)std::distance(v.begin(), v.end());\n}", + "source": "std::distance example", + "length": 149, + "id": 52 + }, + { + "text": "template \nstruct is_contiguous>\n\t: std::true_type {};", + "source": "fmt type trait for std::string", + "length": 151, + "id": 53 + }, + { + "text": "inline auto clz(uint32_t x) -> int {\n\tunsigned long r = 0;\n\t_BitScanReverse(&r, x);\n\treturn 31 ^ static_cast(r);\n}", + "source": "fmt count leading zeros", + "length": 126, + "id": 54 + }, + { + "text": "friend constexpr auto operator==(const uint128_fallback& lhs,\n\tconst uint128_fallback& rhs) -> bool {\n\treturn lhs.hi_ == rhs.hi_ && lhs.lo_ == rhs.lo_;\n}", + "source": "fmt uint128 equality", + "length": 137, + "id": 55 + }, + { + "text": "#include \n\nint main() {\n\tauto now = std::chrono::system_clock::now();\n\tfmt::print(\"Date and time: {}\\n\", now);\n\tfmt::print(\"Time: {:%H:%M}\\n\", now);\n}", + "source": "fmt chrono printing", + "length": 179, + "id": 56 + }, + { + "text": "namespace detail {\n\ntemplate \nconstexpr auto first(const T& value, const Tail&...) -> const T& {\n\treturn value;\n}\n}", + "source": "fmt detail first function", + "length": 152, + "id": 57 + }, + { + "text": "template \nconstexpr auto get_arg_index_by_name(basic_string_view name,\n\ttype_list) -> int {\n\treturn get_arg_index_by_name(name);\n}", + "source": "fmt get_arg_index_by_name", + "length": 193, + "id": 58 + }, + { + "text": "file::~file() noexcept {\n\tif (fd_ != -1 && FMT_POSIX_CALL(close(fd_)) != 0)\n\t\treport_system_error(errno, \"cannot close file\");\n}", + "source": "fmt file destructor", + "length": 136, + "id": 59 + }, + { + "text": "template struct make_unsigned_or_bool : std::make_unsigned {};\ntemplate <> struct make_unsigned_or_bool {\n\tusing type = bool;\n};", + "source": "fmt make_unsigned_or_bool", + "length": 172, + "id": 60 } ] }