doc_id
stringlengths
36
36
metadata
dict
input
stringlengths
28
4.3k
output
stringlengths
11
5.45k
4a5b330e-67e7-43b3-93ae-869972f6c1a0
{ "language": "C++" }
```c++ ``` Add a test case for PR17575.
```c++ // RUN: %clang_cc1 -fsyntax-only -verify %s // expected-no-diagnostics void bar(); namespace foo { using ::bar; } using foo::bar; void bar() {} void f(); using ::f; void f() {} ```
ec691de7-92a2-4269-816f-e0952a05b66d
{ "language": "C++" }
```c++ ``` Add unit test for Character class
```c++ // Copyright (c) 2019 Chris Ohk, Youngjoong Kim, SeungHyun Jeon // We are making my contributions/submissions to this project solely in our // personal capacity and are not conveying any rights to any intellectual // property of any third parties. #include <Utils/TestUtils.hpp> #include "gtest/gtest.h" #inclu...
d986717a-d6ce-4e17-bc8e-f763df4f4994
{ "language": "C++" }
```c++ ``` Add a (currently failing) RTTI layout test.
```c++ // RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -O3 -o - | FileCheck %s #include <typeinfo> class __pbase_type_info : public std::type_info { public: unsigned int __flags; const std::type_info *__pointee; enum __masks { __const_mask = 0x1, __volatile_mask = 0x2, __restrict_mask...
7ce03f80-72a3-4555-b7c2-fef81b992a53
{ "language": "C++" }
```c++ ``` Test for llvm-gcc commit 81037.
```c++ // RUN: %llvmgxx %s -emit-llvm -fapple-kext -S -o - // The extra check in 71555 caused this to crash on Darwin X86 // in an assert build. class foo { virtual ~foo (); }; foo::~foo(){} ```
d24b18b9-e6a4-4559-a907-c1486579ab4e
{ "language": "C++" }
```c++ ``` Add testing code for min-counting.
```c++ #include "cmbf.h" #include <unordered_map> using namespace sketch::cmbf; int main(int argc, char *argv[]) { cmbf_exp_t thing(4, 16, 1); cmbf_t thingexact(4, 16, 5); auto [x, y] = thing.est_memory_usage(); std::fprintf(stderr, "stack space: %zu\theap space:%zu\n", x, y); size_t nitems = arg...
5d95d44b-c5e9-4826-af29-3d4ec5263fe7
{ "language": "C++" }
```c++ ``` Check if a string contain just unique charachers
```c++ #include <iostream> #include <string> #include <vector> using std::string; using std::vector; bool isunique (const string& s); bool isuniqueV2 (const string& s); int main() { string s = "cciao"; if (isuniqueV2(s)) std::cout << "All characters are unique" << std::endl; else std::c...
af23db9c-4cbb-4252-823f-a9f492a90fa4
{ "language": "C++" }
```c++ ``` Print alignment and size of fundamantal and user-defined types
```c++ #include <iostream> #include <iomanip> #include <type_traits> #include <typeinfo> #include <typeindex> class A { }; class A1 { char c; }; class A2 { char c1; char c2; }; class B { char c; int i; }; class C { char c; int i; double d; }; class D { int i; char c; double d; }; class E { ...
4e34133e-138e-4512-8c95-364e2ba9e91d
{ "language": "C++" }
```c++ ``` Add the test that was supposed to be included with r223162.
```c++ // RUN: %clang_cc1 -fsyntax-only -verify %s int w = z.; // expected-error {{use of undeclared identifier 'z'}} \ // expected-error {{expected unqualified-id}} int x = { y[ // expected-error {{use of undeclared identifier 'y'}} \ // expected-note {{to match this '['}} \ ...
782f1364-cb8d-4269-8be3-1d6682ac0efa
{ "language": "C++" }
```c++ ``` Check If a String Contains All Binary Codes of Size K
```c++ class Solution { public: bool hasAllCodes(string s, int k) { if (k > s.size()) { return false; } int need = 1 << k; for (int i = 0; i <= (s.size()-k); ++i) { std::string cur = s.substr(i, k); auto iter = s_.find(cur); if (iter ==...
7e4d05ae-8363-4373-ab78-3155363059e1
{ "language": "C++" }
```c++ ``` Add another testcase missed from r284905.
```c++ // RUN: %clang_cc1 -std=c++1z -verify %s void f() noexcept; void (&r)() = f; void (&s)() noexcept = r; // expected-error {{cannot bind}} void (&cond1)() noexcept = true ? r : f; // expected-error {{cannot bind}} void (&cond2)() noexcept = true ? f : r; // expected-error {{cannot bind}} // FIXME: Strictly, the ...
ffb5a8e5-0635-4b4b-81fb-51044315b7db
{ "language": "C++" }
```c++ ``` Add solution to problem 1
```c++ #include <iostream> using std::cout; using std::endl; template <typename T> struct Node { T data; Node *next; Node(T _data, Node *_next = nullptr) : data(_data), next(_next) {} }; template <typename T> class Stack { Node<T> *top; int size; void clear() { while (!i...
5b829d06-3170-407e-bf62-c9887c6020a2
{ "language": "C++" }
```c++ ``` Remove Duplicates From Sorted Array II
```c++ // // RemoveDuplicatesFromSortedArrayII.cpp // c++ // // Created by sure on 1/20/15. // Copyright (c) 2015 Shuo Li. All rights reserved. // // http://blog.csdn.net/myjiayan/article/details/26334279 // Gives me a better solution. Implement it in C++ #include <stdio.h> class Solution { public: int remove...
41d9b220-4c44-4701-bf39-91ad4268be10
{ "language": "C++" }
```c++ ``` Add dump tests for ArrayInitLoopExpr and ArrayInitIndexExpr
```c++ // RUN: %clang_cc1 -triple x86_64-unknown-unknown -ast-dump %s | FileCheck -strict-whitespace %s void testArrayInitExpr() { int a[10]; auto l = [a]{ }; // CHECK: |-ArrayInitLoopExpr 0x{{[^ ]*}} <col:15> 'int [10]' // CHECK: | `-ArrayInitIndexExpr 0x{{[^ ]*}} <<invalid sloc>> 'unsigned long' ...
eaf25f38-58dd-4b2b-8a3d-70858630bcfa
{ "language": "C++" }
```c++ ``` Add "Circle sort" to the list
```c++ #include<bits/stdc++.h> using namespace std; bool circleSortRec(int a[], int low, int high) { bool swapped = false; if (low == high) return false; int lo = low, hi = high; while (lo < hi) { if (a[lo] > a[hi]) { swap(a[lo], a[hi]...
97792162-f823-4f9d-8ca3-a281b584d58b
{ "language": "C++" }
```c++ ``` Add solution for chapter 18 test 16, test 17
```c++ #include <iostream> namespace Exercise { int ivar = 0; double dvar = 0; const int limit = 1000; } int ivar = 0; //using namespace Exercise; //using Exercise::ivar; //using Exercise::dvar; //using Exercise::limit; void manip() { // using namespace Exercise; using Exercise::ivar...
8c5f194a-f428-4d86-828a-225d5e0a3fd4
{ "language": "C++" }
```c++ ``` Add a test case that goes with the last commit
```c++ // RUN: clang -fsyntax-only -verify %s template<typename T> struct A { }; template<typename T, typename U = A<T*> > struct B : U { }; template<> struct A<int*> { void foo(); }; template<> struct A<float*> { void bar(); }; void test(B<int> *b1, B<float> *b2) { b1->foo(); b2->bar(); } ```
d57d06bf-7d57-4085-95f2-dbc9f3823d55
{ "language": "C++" }
```c++ ``` Test for the algorithm output
```c++ #include <stdio.h> #include <stdlib.h> #include "gtest/gtest.h" #include "test_helper/samples_reader.h" #include "fortune_points/diagram/site.h" #include "fortune_points/diagram/voronoi.h" #include "fortune_points/algorithm/fortune.h" #include "fortune_points/geom/floating_point.h" namespace{ const int NUMBE...
a0387637-a5be-4ed5-abcf-f7e09617ab9f
{ "language": "C++" }
```c++ //===-- PPCPredicates.cpp - PPC Branch Predicate Information --------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===------------------------------------------------...
```c++ //===-- PPCPredicates.cpp - PPC Branch Predicate Information --------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===------------------------------------------------...
a89870d4-31e4-4147-b5a2-21aa1c522f00
{ "language": "C++" }
```c++ ``` Add test for special cases of assignment
```c++ #include "catch.hpp" #include "etl/fast_vector.hpp" #include "etl/fast_matrix.hpp" TEST_CASE( "deep_assign/vec<mat>", "deep_assign" ) { etl::fast_vector<etl::fast_matrix<double, 2, 3>, 2> a; a = 0.0; for(auto& v : a){ for(auto& v2 : v){ REQUIRE(v2 == 0.0); } } } T...
2e2d920d-d623-4414-b50a-d5235c4f7506
{ "language": "C++" }
```c++ ``` Add a test illustrating our current inability to properly cope with the point of instantation of a member function of a class template specialization
```c++ // RUN: clang-cc -fsyntax-only -verify %s // XFAIL // Note: we fail this test because we perform template instantiation // at the end of the translation unit, so argument-dependent lookup // finds functions that occur after the point of instantiation. Note // that GCC fails this test; EDG passes the test in str...
908a164a-c16f-4ff0-a56c-7f3cd7507bcd
{ "language": "C++" }
```c++ ``` Add the solution to "Two arrays".
```c++ #include <iostream> #include <algorithm> using namespace std; bool cmp(int a, int b) { return a > b; } int main() { int T; cin >> T; while (T--) { int n, k; cin >> n >> k; int *a = new int[n]; int *b = new int[n]; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { ...
6cc4e17a-54ba-4baa-9db4-e96bc720b251
{ "language": "C++" }
```c++ ``` Add guidance assembly unit test stub
```c++ #include "engine/guidance/assemble_overview.hpp" #include "engine/guidance/assemble_geometry.hpp" #include "engine/guidance/assemble_steps.hpp" #include "engine/guidance/assemble_route.hpp" #include "engine/guidance/assemble_leg.hpp" #include <boost/test/unit_test.hpp> #include <boost/test/test_case_template.hp...
7b4726bb-3db8-4e51-bb46-a5c8590ba229
{ "language": "C++" }
```c++ ``` Test program for finding bugs in connected_components.
```c++ #include <iostream> #include <cvd/connected_components.h> #include <cvd/image.h> using namespace std; using namespace CVD; int main() { for(int i=0; i < (1<<9); i++) { cout << "------------------------\n" << i << endl; int j=i; vector<ImageRef> p; for(int y=0; y < 3; y++) for(int x=0; x < 3; x++) ...
be57a563-ad1e-42ea-98e6-5a1a76049ef4
{ "language": "C++" }
```c++ ``` Add implementation of Treap in C++
```c++ #include <cstdlib> #include <iostream> #include <string> #include <utility> #include <vector> using namespace std; // Treap has 2 main operations that are O(log(n)): // - split(t, k) -> split t into 2 trees, one with all keys <= k, the other with the rest // - merge(t1, t2) -> merge 2 trees where keys of t1 are...
f461a167-aea7-443d-9505-223ea3426f67
{ "language": "C++" }
```c++ ``` Add Code for finding all nodes at a distanc of K from a given node in a binary tree.
```c++ #include <iostream> #include <queue> using namespace std; // Code for finding all nodes at a distanc of K from a given node in a binary tree. class Node { public: int data; Node *left; Node *right; Node(int x) { data = x; left = NULL; right = NULL; } }; // Function for finding nodes in ...
da6eea43-4061-4000-96ee-db414f4358b6
{ "language": "C++" }
```c++ ``` Add extended euclidean theorem algorithm.
```c++ #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector < ll > vl; vl arr(3); /* returs gcd(a,b) and find the coeficcients of bezout such that d = ax + by arr[0] gcd arr[1] x arr[2] y */ void extended(ll a, ll b){ ll y =0; ll x =1; ll xx =0; ll yy =1; while(b){ ll q = a...
d50d2785-356b-4339-a86f-4405f14fc321
{ "language": "C++" }
```c++ ``` Add example showing the basic usage scenario for static_ptr.
```c++ /* * (C) Copyright 2016 Mirantis Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law ...
3e14dae5-6617-43fc-9cb1-af844bba67b9
{ "language": "C++" }
```c++ ``` Revert "remove test temporarily to debug"
```c++ #include <gtest/gtest.h> TEST(MathMeta, ensure_c11_features_present) { int s[] = {2, 4}; auto f = [&s](auto i) { return i + s[0]; }; EXPECT_EQ(4, f(2)); } ```
0b5f4570-70c2-4d76-9ed2-5da0dacb5379
{ "language": "C++" }
```c++ ``` Add code to insert node in doubly linked list
```c++ #include<iostream> using namespace std; class Node{ public: int data; Node *prev, *next; Node(){} Node(int d){ data=d; prev=NULL; next=NULL; } Node *insertNode(Node *head, int d){ Node *np=new Node(d); Node *t=head; if(head==NULL) return np; while(t->next!=NULL) t=t->next; ...
29cc4b5d-58b8-46ae-b4d0-c2be1b34afac
{ "language": "C++" }
```c++ ``` Change 262430 by wsharp@WSHARP-380 on 2006/12/04 07:26:06
```c++ /* ***** BEGIN LICENSE BLOCK ***** * Version: MPL 1.1/GPL 2.0/LGPL 2.1 * * The contents of this file are subject to the Mozilla Public License Version 1.1 (the * "License"); you may not use this file except in compliance with the License. You may obtain * a copy of the License at http://www.mozilla.org/...
752cf803-3d7e-4f6f-bce0-995399fc03e3
{ "language": "C++" }
```c++ ``` Add runner agent with concepts example.
```c++ #include <atomic> #include <chrono> #include <thread> #include <utility> #include <fmt/printf.h> #include <gsl/gsl_assert> template <typename Agent> concept IsAgent = requires(Agent agent) { {agent.doWork()}; }; template <typename Agent> requires IsAgent<Agent> class Runner { public: Runner(Agent &&agent)...
1626b6f0-20ee-4279-aa60-3917b284d061
{ "language": "C++" }
```c++ ``` Add One Row to Tree
```c++ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode() : val(0), left(nullptr), right(nullptr) {} * TreeNode(int x) : val(x), left(nullptr), right(nullptr) {} * TreeNode(int x, TreeNode *left, TreeNode *right) : va...
9929a64b-de87-41dd-a76e-8170a792c7c0
{ "language": "C++" }
```c++ ``` Add test to demonstrate bug where names are not loaded by the osb loader.
```c++ #include <UnitTest++.h> // Unit tests for vec classes #include <OpenSG/OSGNode.h> #include <OpenSG/OSGNameAttachment.h> #include <OpenSG/OSGSceneFileHandler.h> #include <boost/filesystem/operations.hpp> #include <boost/filesystem/operations.hpp> namespace bf = boost::filesystem; struct FileFixture { File...
6d9a005a-fa84-4d27-923e-aa843071614b
{ "language": "C++" }
```c++ ``` Add libFuzzer style fuzzer for NullGLCanvas for use on OSS-Fuzz.
```c++ /* * Copyright 2018 Google, LLC * * Use of this source code is governed by a BSD-style license that can be * found in the LICENSE file. */ #include "../Fuzz.h" void fuzz_NullGLCanvas(Fuzz* f); extern "C" { // Set default LSAN options. const char *__lsan_default_options() { // Don't print...
6b1121ec-b73b-4850-a38d-e521ebd82e70
{ "language": "C++" }
```c++ ``` Increase Sequence - 466D - Codeforces
```c++ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int mod = 1e9 + 7; int a[2010]; int dp[2010][2010]; int main(void) { int n, h; scanf("%d %d", &n, &h); for (int i = 1; i <= n; i++) scanf("%d", &a[i]); // fill up the base cases dp[1][0] = (a[1] == h || a[1]...
96de66a1-fca5-4ca0-a6e9-38f7a003e7b5
{ "language": "C++" }
```c++ ``` Add max sub array implementaion in C++
```c++ #include <algorithm> #include <iostream> #include <vector> template<typename T> T kadane_method(const std::vector<T>& v){ T ret = 0; std::for_each(v.begin(), v.end(), [c_max = 0, max = 0, &ret](T m) mutable { c_max = c_max + m; // the ccurrent max is a negative number, // we can't use that cuz it will ...
00ac33e6-4f9a-4c58-a171-e2206efd5014
{ "language": "C++" }
```c++ ``` Add basic wrapper for Douglas-Peucker
```c++ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ /* psimpl-c Copyright (c) 2013 Jamie Bullock <jamie@jamiebullock.com> Based on psimpl Copyright (c) 2...
ed5f210d-e508-4fc6-8a48-1743f80d6d69
{ "language": "C++" }
```c++ ``` Add method to unify all exit nodes of a method
```c++ //===- SimplifyCFG.cpp - CFG Simplification Routines -------------*- C++ -*--=// // // This file provides several routines that are useful for simplifying CFGs in // various ways... // //===----------------------------------------------------------------------===// #include "llvm/Analysis/SimplifyCFG.h" #includ...
b7618c1c-e856-4660-9eda-744dd551572b
{ "language": "C++" }
```c++ #include "generator/geo_objects/geo_objects_filter.hpp" #include "generator/osm_element_helpers.hpp" #include "indexer/ftypes_matcher.hpp" using namespace feature; namespace generator { namespace geo_objects { bool GeoObjectsFilter::IsAccepted(OsmElement const & element) { return osm_element::IsBuilding(el...
```c++ #include "generator/geo_objects/geo_objects_filter.hpp" #include "generator/osm_element_helpers.hpp" #include "indexer/ftypes_matcher.hpp" using namespace feature; namespace generator { namespace geo_objects { bool GeoObjectsFilter::IsAccepted(OsmElement const & element) { return osm_element::IsBuilding(el...
2ed5974a-3eb0-4cd2-adac-5f702cb632dc
{ "language": "C++" }
```c++ ``` Add Chapter 20, exercise 4
```c++ // Chapter 20, Exercise 04: Find and fix the errors in the Jack-and-Jill example // from 20.3.1 by using STL techniques throughout. #include "../lib_files/std_lib_facilities.h" double* get_from_jack(int* count) { string ifname = "pics_and_txt/chapter20_ex02_in1.txt"; ifstream ifs(ifname.c_str()); i...
a444632e-bc7c-4490-ac41-c018322e51d6
{ "language": "C++" }
```c++ // Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "media/base/media.h" #include "base/logging.h" // This file is intended for platforms that don't need to load any media // libraries (e....
```c++ // Copyright 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "media/base/media.h" #include "base/logging.h" #if defined(OS_ANDROID) #include "base/android/jni_android.h" #include "media/base/androi...
95bbed07-2e51-46c6-9613-3d504297ea22
{ "language": "C++" }
```c++ ``` Add test cases for ConditionVariable
```c++ /* mbed Microcontroller Library * Copyright (c) 2017 ARM Limited * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless ...
ae692688-e4e0-4c36-af0d-71c685dad78e
{ "language": "C++" }
```c++ ``` Add a test case for PR1420
```c++ // Test case for PR1420 // RUN: %llvmgxx %s -O0 -o %t.exe // RUN: %t.exe > %t.out // RUN: grep {sizeof(bitFieldStruct) == 8} %t.out // RUN: grep {Offset bitFieldStruct.i = 0} %t.out // RUN: grep {Offset bitFieldStruct.c2 = 7} %t.out // XFAIL: * #include <stdio.h> class bitFieldStruct { public: int i; ...
805c569e-7b08-433e-9403-de606d312a03
{ "language": "C++" }
```c++ ``` Add struct alignement test example.
```c++ #include <cassert> #include <cstdint> #include <iostream> #include <malloc.h> #include <new> class alignas(32) Vec3d { double x, y, z; }; int main() { std::cout << "sizeof(Vec3d) is " << sizeof(Vec3d) << '\n'; std::cout << "alignof(Vec3d) is " << alignof(Vec3d) << '\n'; auto Vec = Vec3d{}; ...
2220bfb4-32db-43c4-9852-e629b3c11005
{ "language": "C++" }
```c++ ``` Add the forgotten test file.
```c++ // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -verify %s // expected-no-diagnostics // Test functions that are called "memcpy" but aren't the memcpy // we're looking for. Unfortunately, this test cannot be put into // a namespace. The out-of-class weird memcpy needs to be recognized // as a normal C f...
14fdbdd6-f50b-48df-b508-6ee8c28400f0
{ "language": "C++" }
```c++ ``` Add testcase missed yesterday. Patch from Paul Robinson.
```c++ // RUN: %clangxx -g -O0 %s -emit-llvm -S -o - | FileCheck %s // PR14471 class C { static int a; const static int const_a = 16; protected: static int b; const static int const_b = 17; public: static int c; const static int const_c = 18; int d; }; int C::a = 4; int C::b = 2; int C::c = 1; int mai...
ad88d9e9-68e1-4acc-b359-e3384f0cf675
{ "language": "C++" }
```c++ ``` Implement tests for NULL iterators for <array> re: N3644
```c++ //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===---------------------------------...
457b1c18-3c02-4799-9a09-2fd67ede6a81
{ "language": "C++" }
```c++ ``` Prepare exercise 4 from chapter 9.
```c++ // 9.exercise.04.cpp // // Look at the headache-inducing last example of §8.4. Indent it properly and // explain the meaning of the construct. Note that the example doesn't do // anything meaningful; it is pure obfuscation. // // COMMENTS int maint() try { return 0; } catch(exception& e) { cerr << ...
b1269702-c0f7-4870-a308-a3ce8d1aabb3
{ "language": "C++" }
```c++ ``` Add solution to task 1
```c++ #include <iostream> #include <cstring> using namespace std; class Card { char title[100]; char author[100]; unsigned int count; public: Card(const char _title[], const char _author[], unsigned int _count) { strcpy(title, _title); strcpy(author, _author); count = _count...
b9dfedd4-bd22-4cf1-9183-775ec4c286d4
{ "language": "C++" }
```c++ ``` Add solution to the first problem - '3D point'
```c++ #include <iostream> #include <cmath> using namespace std; class Point3D { double x; double y; double z; public: double getX() { return x; } double getY() { return y; } double getZ() { return z; } void setX(double newX) { x = newX; } void setY(double newY) { y =...
97c71246-9ae8-428e-9b09-caf4685c5334
{ "language": "C++" }
```c++ ``` Add a test for re-initialising FDR mode (NFC)
```c++ // RUN: %clangxx_xray -g -std=c++11 %s -o %t // RUN: rm xray-log.fdr-reinit* || true // RUN: XRAY_OPTIONS="verbosity=1" %run %t // RUN: rm xray-log.fdr-reinit* || true #include "xray/xray_log_interface.h" #include <cassert> #include <cstddef> #include <thread> volatile uint64_t var = 0; std::atomic_flag keep_g...
bd820c87-bb43-453c-b914-d4068badd90b
{ "language": "C++" }
```c++ ``` Set scale factor to the value in gsettings
```c++ // Copyright (c) 2014 GitHub, Inc. All rights reserved. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #include "atom/browser/atom_browser_main_parts.h" #include "base/command_line.h" #include "base/strings/string_number_conversions.h" #include "library_load...
4ba23ef7-6413-4f28-9733-814de1ce55f0
{ "language": "C++" }
```c++ #include "go_quic_spdy_server_stream_go_wrapper.h" #include "net/quic/quic_session.h" #include "net/quic/quic_data_stream.h" #include "go_functions.h" GoQuicSpdyServerStreamGoWrapper::GoQuicSpdyServerStreamGoWrapper(net::QuicStreamId id, net::QuicSession* session, void* go_quic_spdy_server_stream) : net::Qui...
```c++ #include "go_quic_spdy_server_stream_go_wrapper.h" #include "net/quic/quic_session.h" #include "net/quic/quic_data_stream.h" #include "go_functions.h" GoQuicSpdyServerStreamGoWrapper::GoQuicSpdyServerStreamGoWrapper(net::QuicStreamId id, net::QuicSession* session, void* go_quic_spdy_server_stream) : net::Qui...
a18c6936-c2dd-41b0-ba70-ebd44223d812
{ "language": "C++" }
```c++ ``` Add a solution for task 1a
```c++ #include <cstdio> #include <cstring> using namespace std; int binary_to_decimal(char * number) { int result = 0; int power = 0; for (int i = strlen(number) - 1; i >= 0; i--) { int x = number[i] - '0'; result += x * (1 << power); power++; } return result; } int octal_to_decimal(char *...
ab72e176-d081-4041-a47b-80aba3abcc34
{ "language": "C++" }
```c++ ``` Add test that GDAL plugin does not upsample.
```c++ /***************************************************************************** * * This file is part of Mapnik (c++ mapping toolkit) * * Copyright (C) 2015 Artem Pavlenko * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * Licen...
ff404836-4998-42f7-87f5-1fbd8b6b4b4e
{ "language": "C++" }
```c++ ``` Add solution for chapter 18, test 29
```c++ #include <iostream> using namespace std; class Class { public: Class() { cout << "Class()" << endl; } }; class Base : public Class { public: Base() { cout << "Base()" << endl; } }; class D1 : virtual public Base { public: D1() { cout << "D1()" ...
d6658b86-8a78-4552-81a9-c894467510c3
{ "language": "C++" }
```c++ ``` Add example of clang attributes for prevention of use after move.
```c++ #include <iostream> #include <cassert> class [[clang::consumable(unconsumed)]] Object { public: Object() {} Object(Object&& other) { other.invalidate(); } [[clang::callable_when(unconsumed)]] void do_something() { assert(m_valid); } private: [[clang::set_typestate(consumed)]] void inval...
2f6b5805-1273-4e3f-b6ef-687263d61dc6
{ "language": "C++" }
```c++ ``` Add an experiment that tests some bitfield stuff
```c++ #include <atomic> #include <thread> #include <iostream> struct thing { unsigned int a : 15; unsigned int b : 15; }; thing x; void f1(int n) { for (int i = 0; i < n; i++) { x.a++; } } void f2(int n) { for (int i = 0; i < n; i++) { x.b++; } } int main() { std::cout ...
c465fa5b-a9ff-4524-a642-b95e5e131b9f
{ "language": "C++" }
```c++ ``` Add new test that shows failure in DerivativeApproximation
```c++ //---------------------------- crash_04.cc --------------------------- // $Id$ // Version: $Name$ // // Copyright (C) 2005, 2006 by the deal.II authors // // This file is subject to QPL and may not be distributed // without copyright and license information. Please refer // to the file deal...
a6a01060-18b8-4525-ba9b-229b9d452faf
{ "language": "C++" }
```c++ ``` Add minimal testcase for optimizer bug in FParser.
```c++ // Simple example file for the the fparser optimization bug // (c) 2014 by Daniel Schwen // ======================================================== // $CXX -o optimizer_bug optimizer_bug.cc -I ../../../installed/include/libmesh/ ../../../build/contrib/fparser/.libs/libfparser_la-fp* #include "../fparser.hh" ...
49aca0ce-cbbe-48ba-b20f-c19bdf68b63b
{ "language": "C++" }
```c++ ``` Add solution for chapter 19, test 13
```c++ #include <iostream> #include <string> #include "test16_62_Sales_data.h" using namespace std; int main() { Sales_data item("book1", 4, 30.0), *p = &item; auto pdata = &Sales_data::isbn; cout << (item.*pdata)() << endl; cout << (p ->* pdata)() << endl; return 0; } ```
99c71394-a560-4010-8beb-39441fbfb7a3
{ "language": "C++" }
```c++ ``` Test for the new FileUtil::GetFileName() functions.
```c++ /** \file xml_parser_test.cc * \brief Tests the FileUtil::GetFileName() function. * \author Dr. Johannes Ruscheinski */ /* Copyright (C) 2015, Library of the University of Tübingen This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero G...
f716e94a-b8be-4bdb-82c7-32c4a7a9c5d7
{ "language": "C++" }
```c++ ``` Add in Intel TBB tests
```c++ #include "tbb/parallel_sort.h" #include <math.h> using namespace tbb; const int N = 100000; float a[N], b[N], c[N], d[N]; void SortExample() { for( int i = 0; i < N; i++ ) { a[i] = sin((double)i); b[i] = cos((double)i); c[i] = 1/sin((double)i); d[i] = 1/cos((double)i); } parallel_sor...
540879d1-54dd-42b6-bb9a-27a27864ba07
{ "language": "C++" }
```c++ ``` Add basic test for Vec2
```c++ #include "gtest/gtest.h" #include "gmock/gmock.h" #include "Vec2i.h" TEST(TestVec2i, DisplacingDirectionWithOffsetWillWrap ) { ASSERT_EQ( Knights::EDirection::kWest, Knights::wrapDirection( Knights::EDirection::kNorth, -1 ) ); ASSERT_EQ( Knights::EDirection::kNorth, Knights::wrapDirection( Knights:...
c25e66f0-ee8e-4a10-8c46-2605d97b8b2e
{ "language": "C++" }
```c++ ``` Add the vpsc library for IPSEPCOLA features
```c++ /** * * Authors: * Tim Dwyer <tgdwyer@gmail.com> * * Copyright (C) 2005 Authors * * This version is released under the CPL (Common Public License) with * the Graphviz distribution. * A version is also available under the LGPL as part of the Adaptagrams * project: http://sourceforge.net/projects/adapt...
fcb554af-9c2a-4977-b0a0-5d03ee58a7e9
{ "language": "C++" }
```c++ ``` Make sure C++ protection shows up in debug info
```c++ // RUN: %llvmgxx -O0 -emit-llvm -S -g -o - %s | grep 'uint 1,' && // RUN: %llvmgxx -O0 -emit-llvm -S -g -o - %s | grep 'uint 2,' class A { public: int x; protected: int y; private: int z; }; A a; ```
8a598113-7c70-4f03-ae31-60b8533c1457
{ "language": "C++" }
```c++ ``` Add image generation demo file.
```c++ // // Programmer: Craig Stuart Sapp <craig@ccrma.stanford.edu> // Creation Date: Mon 18 Apr 2022 06:34:46 PM UTC // Last Modified: Mon 18 Apr 2022 06:34:49 PM UTC // Filename: imagedemo.cpp // URL: https://github.com/craigsapp/humlib/blob/master/cli/imagedemo.cpp // Syntax: C++11 // vim:...
f9017b8c-15b1-4cb2-a1a1-d29e3b5e8d98
{ "language": "C++" }
```c++ ``` Divide a String Into Groups of Size k
```c++ class Solution { public: vector<string> divideString(string s, int k, char fill) { std::vector<std::string> ret; std::string cur; for (int i = 0; i < s.size(); i += k) { ret.emplace_back(s.substr(i, k)); } while (ret[ret.size()-1].size() < k) { ...
c03c5fe6-6b6c-4e0d-a071-6a3941b74a1c
{ "language": "C++" }
```c++ ``` Validate if a binary tree is BST
```c++ /** * Definition for a binary tree node. * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(NULL), right(NULL) {} * }; */ class Solution { public: inline bool isLeaf(TreeNode* n) { return n->left == NULL && n->right == NULL; ...
05e54766-12d4-4d9a-aac8-3f5a5504c5b4
{ "language": "C++" }
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profi...
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/extensions/extension_apitest.h" #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profi...
0465aca2-e655-4393-b258-76564a59ac91
{ "language": "C++" }
```c++ ``` Add a testcase to check that initializer that CAN be evaluated statically ARE.
```c++ // RUN: %llvmgxx %s -S -o - | grep '%XX = global int 4' struct S { int A[2]; }; int XX = (int)&(((struct S*)0)->A[1]); ```
4aeb1992-37e6-4eab-8179-6960dddfc300
{ "language": "C++" }
```c++ ``` Add code to print linked list
```c++ #include<iostream> using namespace std; class Node{ public: int data; Node *next,*head; Node(){} Node(int d){ data=d; next=NULL; } Node *addElement(Node *head, int d){ Node *nde=new Node(d); Node *tmp=head; if(head==NULL) return nde; else{ while(tmp->next) tmp=tmp->next; } ...
16ef7d2d-e655-4bd7-ba2a-77e973edda21
{ "language": "C++" }
```c++ ``` Add idiom to read lines from a file.
```c++ #include <iostream> #include <fstream> int main() { std::ifstream file("data.txt"); std::string line; // See: https://stackoverflow.com/q/7219062/496459 // std::getline has no buffer-size limitation, per the standard. while(std::getline(file, line)) { std::cout << line << '\n'; ...
d15a57a3-6983-4b16-b54a-6d034f1bd015
{ "language": "C++" }
```c++ ``` Add trivial gemm test for multithread consistency
```c++ #include <iostream> #include <cblas.h> int main ( int argc, char* argv[] ) { const long n = ((long)1 << 31) - 1; std::cout << n <<std::endl; float* A = new float[n]; float* B = new float[n]; float* C = new float[1]; for(long i =0; i <n; i++){ A[i] = 1; B[i] = 1; } ...
deabe1e7-aed4-4459-be73-3e274fc500c0
{ "language": "C++" }
```c++ ``` Add the solution to "QuickSort1 - Partition".
```c++ #include <iostream> #include <cstring> using namespace std; void swap(int &a, int &b) { int temp = a; a = b; b = temp; } void reverse(int *a, int start, int end) { for (int i = 0; i < (end - start + 1) / 2; i++) { swap(a[start + i], a[end - i]); } } void partition(int *a, int n) { int *temp = new int[...
911f0e90-2f5c-4216-865a-f2246b217fa4
{ "language": "C++" }
```c++ ``` Verify Preorder Serialization of a Binary Tree
```c++ class Solution { public: bool isValidSerialization(string preorder) { vector<string> h; string t; for(int i=0;i<preorder.size();){ if(preorder[i]==','){ h.push_back(t); t.erase(t.begin(),t.end()); preorder.erase(preorder.begi...
fd1f829a-e0a6-470c-addf-4f2f12562864
{ "language": "C++" }
```c++ #include <iostream> #include <interpreter.h> #include <gui.h> #include <easylogging++.h> #include <SFML/Graphics.hpp> INITIALIZE_EASYLOGGINGPP int main(int argc, char *argv[]) { START_EASYLOGGINGPP(argc, argv); int i = foo(); std::cout << str() + 1 << std::endl << i << std::endl; LOG(INFO) << ...
```c++ #include <iostream> #include <interpreter.h> #include <gui.h> #include <easylogging++.h> #include <SFML/Graphics.hpp> INITIALIZE_EASYLOGGINGPP int main(int argc, char *argv[]) { START_EASYLOGGINGPP(argc, argv); std::cout << "Who am I ? where am I ? Lei" << std::endl; int i = foo(); std::co...
86255118-638e-4b05-aba3-2824a4d82f49
{ "language": "C++" }
```c++ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "sandbox/linux/services/resource_limits.h" #include <errno.h> #include <sys/resource.h> #include <sys/time.h> #include <unistd.h> #inclu...
```c++ // Copyright 2015 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "sandbox/linux/services/resource_limits.h" #include <errno.h> #include <sys/resource.h> #include <sys/time.h> #include <unistd.h> #inclu...
b13ee40a-8799-4a24-aa77-f4578d3cc820
{ "language": "C++" }
```c++ ``` Add Chapter 20, exercise 15
```c++ // Chapter 20, Exercise 15: define a pvector to be like a vector of pointers // except that it contains pointer to objects and its destructor deletes each // object #include "../lib_files/std_lib_facilities.h" //------------------------------------------------------------------------------ template<class Elem...
e07d2ea0-ff4f-4170-ba8c-4a96ec107bd3
{ "language": "C++" }
```c++ ``` Add solution for chapter 17 test 4
```c++ #include <iostream> #include <tuple> #include <algorithm> #include <vector> #include <string> #include "test16_62_Sales_data.h" using namespace std; bool compareIsbn(const Sales_data &lhs, const Sales_data &rhs) { return lhs.isbn() < rhs.isbn(); } typedef tuple<vector<Sales_data>::size_type...
c77c53fb-a8d5-470a-8c5d-9f9178f606e9
{ "language": "C++" }
```c++ ``` Add solution to first problem
```c++ #include <iostream> using namespace std; const int MAX = 100; struct Person { string firstName; string lastName; void input() { cout << "Enter person's first and last names separated by a space: "; cin >> firstName >> lastName; } void print() { cout << firstName << ' ' << lastName << '...
fc6284ce-99f8-48be-b777-6a0d5ffe1bf0
{ "language": "C++" }
```c++ // Copyright (c) 2013 GitHub, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #include "atom/browser/javascript_environment.h" #include "base/command_line.h" #include "gin/array_buffer.h" #include "gin/v8_initializer.h" namespace atom { JavascriptEnvir...
```c++ // Copyright (c) 2013 GitHub, Inc. // Use of this source code is governed by the MIT license that can be // found in the LICENSE file. #include <string> #include "atom/browser/javascript_environment.h" #include "base/command_line.h" #include "gin/array_buffer.h" #include "gin/v8_initializer.h" namespace atom...
4c75af3a-91b6-45de-9f91-61a73872712b
{ "language": "C++" }
```c++ ``` Add a test for FocusCycle.
```c++ #include <iostream> #include <vector> #include <UnitTest++.h> #include "model/focus-cycle.h" #include "logging/logging.h" #include "logging/stream.h" const int last_window = 9; StreamLog log(std::cerr); struct FocusCycleFixture { FocusCycle cycle; std::vector<Window> windows; FocusCycleFixture() ...
36e1abdf-b331-434d-a763-871139d588ee
{ "language": "C++" }
```c++ ``` Add unit test for TaskBase.
```c++ #include "TaskBase.h" #include <gtest/gtest.h> #include <unistd.h> using namespace tpool; namespace { struct FakeTask : public TaskBase { virtual void DoRun() { sleep(2); } }; } TEST(TaskBase, test_GetState) { FakeTask task; EXPECT_EQ(TaskBase::INIT, task.GetState()); } ```
f012dc0d-9350-40cf-9d4d-fa5311677405
{ "language": "C++" }
```c++ ``` Add a missing test case for places view.
```c++ #include <QApplication> #include <QMainWindow> #include <QToolBar> #include <QDir> #include <QDebug> #include "../placesview.h" #include "libfmqt.h" int main(int argc, char** argv) { QApplication app(argc, argv); Fm::LibFmQt contex; QMainWindow win; Fm::PlacesView view; win.setCentralWidge...
12201bfd-9450-4ca4-83f9-df9364482962
{ "language": "C++" }
```c++ ``` Add a missing test for the limits on wchar
```c++ // RUN: %clang_cc1 -fsyntax-only -verify %s // RUN: %clang_cc1 -fsyntax-only -verify -fshort-wchar %s #include <limits.h> const bool swchar = (wchar_t)-1 > (wchar_t)0; #ifdef __WCHAR_UNSIGNED__ int signed_test[!swchar]; #else int signed_test[swchar]; #endif int max_test[WCHAR_MAX == (swchar ? -(WCHAR_MIN+1) ...
b41749d7-30f2-4a93-9f72-d6683b95482f
{ "language": "C++" }
```c++ ``` Check power of 2 cpp
```c++ #include <iostream> using namespace std; bool check_pow_2(int num) { if ((num & (num-1)) == 0) return true; return false; } int main() { int num = 2; check_pow_2(num) ? cout << "Num is a Power of 2" : cout << "Num is not a power of 2"; cout << endl; num = 5; check_pow_2(num)...
cf5220af-ad1c-4ab9-a6bc-d14a8233c83e
{ "language": "C++" }
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" #include "base/rand_util.h" #include "build/build_config.h" #if defin...
```c++ // Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/sync/glue/chrome_report_unrecoverable_error.h" #include "base/rand_util.h" #include "build/build_config.h" #if defin...
72fd283f-ee08-4e09-a5fe-3ca013c68e9d
{ "language": "C++" }
```c++ ``` Test that deleting destructor thunks are not exported
```c++ // RUN: %clang_cc1 -mconstructor-aliases -fms-extensions %s -emit-llvm -o - -triple x86_64-windows-msvc | FileCheck %s struct __declspec(dllexport) A { virtual ~A(); }; struct __declspec(dllexport) B { virtual ~B(); }; struct __declspec(dllexport) C : A, B { virtual ~C(); }; C::~C() {} // This thunk should *no...
102b89dd-9891-4e35-9e22-7b8b1a2d7a8f
{ "language": "C++" }
```c++ ``` Add the first version of the RTL thunk that should be linked with instrumented DLLs
```c++ //===-- asan_dll_thunk.cc -------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===------------------------------------------------...
c88c90b0-5e5d-485b-9cf8-3925291c399a
{ "language": "C++" }
```c++ ``` Add solution for chapter 16 test 39.
```c++ #include <iostream> #include <string> #include "test16_2_compare.h" using namespace std; template <typename It> auto fcn3(It beg, It end) -> decltype(*beg + 0) { return *beg; } int main() { cout << compare<char*>("hi", "world") << endl; cout << compare<string>("dad", "bye") << end...
d03d9f22-3d79-4ed2-9597-c193b60c4ebd
{ "language": "C++" }
```c++ ``` Add an example of using the benchmark system to choose the fastest SHA-1 implementation and then setting it as the default.
```c++ #include <botan/botan.h> #include <botan/benchmark.h> #include <botan/filters.h> #include <iostream> #include <fstream> #include <string> #include <map> #include <cstdlib> /* Try to find the fastest SHA-1 implementation and use it to hash files. In most programs this isn't worth the bother and overhead. Howeve...
a325ad62-ab61-4a30-a1da-8f563167507f
{ "language": "C++" }
```c++ ``` Add test program for counting sort
```c++ /* This program tests Counting sort */ #include<iostream> #include<vector> #include "countingsort.h" // My implementation of Counting sort // Displays vector void printVector(std::vector<int> A){ for(auto x: A){ std::cout<<x<<" "; } std::cout<<std::endl; } // Tests Counting sort on vector A void te...
c36f793b-ab67-40c2-87dc-f94e90f000f7
{ "language": "C++" }
```c++ ``` Add example for SyncFolderHierarchy operation
```c++ // Copyright 2018 otris software AG // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by appli...
e434cc05-239b-4806-bfc3-265695b30d97
{ "language": "C++" }
```c++ ``` Add test case for PR31384
```c++ // -*- C++ -*- //===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is dual licensed under the MIT and the University of Illinois Open // Source Licenses. See LICENSE.TXT for details. // //===------------------...
8dddc471-89f3-4914-bbda-cf5b70d6b05c
{ "language": "C++" }
```c++ ``` Add simple wire protocol test
```c++ //===----------------------------------------------------------------------===// // // Peloton // // packet_manager_test.cpp // // Identification: test/wire/packet_manager_test.cpp // // Copyright (c) 2016-17, Carnegie Mellon University Database Group // //===-----------------------------...
fa3a2bf2-5b05-46cd-b214-f76d8957ea09
{ "language": "C++" }
```c++ AliAnalysisTaskStrangenessLifetimes *AddTaskStrangenessLifetimes( TString tskname = "LifetimesFiltering", TString suffix = "") { // Get the current analysis manager AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); if (!mgr) { Error("AddTaskStrangenessLifetimes", "No analysis mana...
```c++ AliAnalysisTaskStrangenessLifetimes *AddTaskStrangenessLifetimes(bool isMC = false, TString tskname = "LifetimesFiltering", TString suffix = "") { // Get the current analysis manager AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager(); if (!mgr) { Error("AddTaskStrangenessLifetimes",...
11d1f2b0-2d44-42ee-afa8-eb23fcab58fb
{ "language": "C++" }
```c++ ``` Add a solution for problem 79: Word Search.
```c++ // https://leetcode.com/problems/word-search/ // Using a DFS solution, stop as early as possible. class Solution { bool dfs(const vector<vector<char> > &board, int r, int c, const char* word, vector<vector<bool> >* visited){ if (*word != board[r][c]) { ...
81bd2f3b-d2a5-459a-b8b4-49ec703cd3d6
{ "language": "C++" }
```c++ /** * @file main.cpp * @author Volodymyr Shymanskyy * @license This project is released under the MIT License (MIT) * @copyright Copyright (c) 2015 Volodymyr Shymanskyy * @date Mar 2015 * @brief */ //#define BLYNK_DEBUG #define BLYNK_PRINT stdout #ifdef RASPBERRY #include <BlynkApiWi...
```c++ /** * @file main.cpp * @author Volodymyr Shymanskyy * @license This project is released under the MIT License (MIT) * @copyright Copyright (c) 2015 Volodymyr Shymanskyy * @date Mar 2015 * @brief */ //#define BLYNK_DEBUG #define BLYNK_PRINT stdout #ifdef RASPBERRY #include <BlynkApiWi...
a04e71e8-4f80-4f7b-8b57-90e308d11d50
{ "language": "C++" }
```c++ ``` Add test for gpu assertions
```c++ #include "Halide.h" using namespace Halide; bool errored = false; void my_error(void *, const char *msg) { printf("Expected error: %s\n", msg); errored = true; } void my_print(void *, const char *msg) { // Empty to neuter debug message spew } int main(int argc, char **argv) { Target t = get_j...