├── src
├── arrays
│ ├── text.html
│ ├── dangerous_main.cc
│ └── BUILD
├── lib
│ ├── inheritance
│ │ └── main.cc
│ ├── segment_tree
│ │ ├── segment_tree.cc
│ │ └── BUILD
│ ├── consonant_vowel_imbalance
│ │ ├── consonant_vowel_imbalance.cc
│ │ └── BUILD
│ ├── solution.cc
│ ├── sort
│ │ └── BUILD
│ ├── search
│ │ ├── BUILD
│ │ └── search.h
│ ├── backtracking
│ │ └── BUILD
│ ├── dynamic_programming
│ │ ├── BUILD
│ │ └── dynamic_programming.h
│ ├── vector_union.h
│ ├── bst.h
│ ├── vector_union.cc
│ ├── graph
│ │ ├── adjacency_matrix.h
│ │ ├── vector_v_vector_pair_e.h
│ │ ├── adjacency_vector_of_set.h
│ │ ├── adjacency_vector_of_set.cc
│ │ ├── pointer.h
│ │ └── vector_v_vector_pair_e.cc
│ ├── solution.h
│ ├── factory
│ │ ├── img_create.h
│ │ └── img_create_map.h
│ ├── bst.cc
│ ├── heap.h
│ └── tree.h
├── string_view
│ ├── output
│ │ └── string_view_benchmark.csv
│ └── BUILD
├── benchmark
│ ├── lib.h
│ ├── lib.cc
│ ├── output
│ │ ├── plus_equal.csv
│ │ ├── search_collection.csv
│ │ ├── split_string.csv
│ │ └── insert_into_collection.csv
│ └── variable_in_loop.cc
├── deep_c
│ ├── 33.cc
│ ├── 245.cc
│ ├── main.cc
│ ├── 379.cc
│ ├── BUILD
│ └── 388.cc
├── stack
│ ├── BUILD
│ └── main.cc
├── cpp17
│ ├── Ex01
│ │ └── BUILD
│ ├── file_system3.cc
│ ├── if_constexpr.cc
│ ├── file_system4.cc
│ ├── no_discard.cc
│ ├── template_auto.cc
│ ├── if_init.cc
│ └── memory_resources.cc
├── cpp20
│ ├── BUILD
│ └── coroutine.cc
├── tbb
│ └── BUILD
├── preprocessor
│ ├── hazf.h
│ ├── BUILD
│ ├── xmacro.cc
│ └── tokens.h
├── explicit
│ ├── BUILD
│ └── main.cc
├── tuple
│ ├── BUILD
│ └── main.cc
├── enum
│ └── BUILD
├── hello_world
│ ├── BUILD
│ └── main.cc
├── nullptr
│ ├── BUILD
│ └── main.cc
├── queue
│ └── BUILD
├── string
│ └── BUILD
├── linked_list
│ ├── BUILD
│ └── main.cc
├── patterns
│ ├── proxy
│ │ ├── BUILD
│ │ └── main.cc
│ ├── adapter
│ │ └── BUILD
│ ├── mediator
│ │ ├── BUILD
│ │ └── main.cc
│ ├── memento
│ │ └── BUILD
│ ├── observer
│ │ └── BUILD
│ ├── singleton
│ │ ├── BUILD
│ │ └── main.cc
│ └── factory
│ │ └── BUILD
├── override
│ ├── BUILD
│ └── main.cc
├── priority_queue
│ ├── BUILD
│ └── main.cc
├── sort
│ ├── BUILD
│ └── main.cc
├── uniform_initialization
│ ├── BUILD
│ ├── initializer_list
│ │ ├── BUILD
│ │ ├── explicit_constructor_vs_cast.cc
│ │ ├── variable_arguments.cc
│ │ └── explicit_constructor.cc
│ ├── main.cc
│ └── aggregate_initialization.cc
├── vector
│ └── BUILD
├── list
│ └── BUILD
├── pointers
│ ├── pointer_to_void
│ │ ├── BUILD
│ │ └── main.cc
│ ├── void_pointer
│ │ └── BUILD
│ ├── set_new_handler.cc
│ ├── deep_copy_main.cc
│ ├── shallow_copy_main.cc
│ ├── BUILD
│ ├── unsafe_pointers_main.cc
│ └── heap_main.cc
├── moving_average
│ └── BUILD
├── heap
│ └── BUILD
├── const
│ ├── main.cc
│ ├── main copy.cc
│ ├── mutable.cc
│ ├── BUILD
│ └── const_functions.cc
├── questions
│ └── sharks
│ │ └── BUILD
├── templates
│ ├── factorial.cc
│ ├── create_op.cc
│ ├── member_templates.cc
│ ├── meta_programming.cc
│ ├── non_type.cc
│ ├── variadic_with_init_list.cc
│ ├── numbers.cc
│ ├── parameter_independant.cc
│ ├── fibonacci.cc
│ ├── enable_if.cc
│ ├── static_assert.cc
│ ├── is_same.cc
│ ├── traits.cc
│ ├── is_char.cc
│ ├── non_member_functions_inside_templates.cc
│ ├── specialized.cc
│ └── alias_template.cc
├── decltype
│ ├── BUILD
│ └── find_deduced_type.cc
├── move
│ ├── swap.cc
│ ├── copy_ellision_main.cc
│ ├── move_so_main.cc
│ ├── copy_elision.cc
│ ├── perfect_forwarding.cc
│ ├── std_forward.cc
│ └── copy_assignment.cc
├── typeid
│ ├── BUILD
│ ├── 2.cc
│ └── main.cc
├── main
│ ├── BUILD
│ ├── main.cc
│ └── bishop_moves.cc
├── smart_pointer
│ ├── pimple
│ │ ├── main.cc
│ │ ├── BUILD
│ │ ├── widget.h
│ │ └── widget.cc
│ ├── stl_unique_main.cc
│ ├── BUILD
│ └── shared_ptr_costum_delete copy.cc
├── stl_algorithm
│ └── BUILD
├── result_of
│ ├── BUILD
│ └── invoke.cc
├── amortization
│ ├── BUILD
│ └── binary_counter_main.cc
├── set_examples
│ ├── BUILD
│ ├── vector_union_main.cc
│ └── set_insert_n_items_main.cc
├── graph
│ ├── shortest_path
│ │ └── BUILD
│ ├── pointer_main.cc
│ ├── vector_v_vector_pair_e_main.cc
│ ├── adjacency_vector_of_set_main.cc
│ ├── set_v_set_pair_e_main.cc
│ ├── adjacency_matrix_main.cc
│ ├── map_main.cc
│ ├── set_of_set.cc
│ ├── vector_of_set.cc
│ └── unordered_set_of_unordered_set.cc
├── opreators
│ ├── bool_main.cc
│ ├── BUILD
│ └── float_main.cc
├── random
│ ├── rand_main.cc
│ ├── uniform_bind_main.cc
│ ├── uniform_main.cc
│ ├── uniform_float_main.cc
│ └── BUILD
├── cast
│ ├── BUILD
│ └── static_cast_constructor.cc
├── scope
│ ├── namespace_unnamed_main.cc
│ ├── BUILD
│ ├── namespace_nested_main.cc
│ ├── namespace_extend_main.cc
│ └── namespace_main.cc
├── cpp14
│ ├── deprecated.cc
│ ├── BUILD
│ ├── return_type_deduction.cc
│ ├── lambda_capture_init.cc
│ ├── generic_lambda.cc
│ └── other.cc
├── variables
│ ├── BUILD
│ ├── float_main.cc
│ └── main.cc
├── constructor
├── tree
│ ├── main.cc
│ ├── BUILD
│ └── std_any_main.cc
├── references
│ ├── pointer_vs_reference_main.cc
│ ├── main.cc
│ ├── BUILD
│ └── references_in_loops_main.cc
├── exceptions
│ ├── stack_unwinding2.cc
│ ├── std_exception.cc
│ └── BUILD
├── control
│ ├── switch_main.cc
│ ├── BUILD
│ ├── if_main.cc
│ └── while_main.cc
├── memory_allocator
│ ├── main3.cc
│ ├── std_allocator1.cc
│ ├── global_new_delete.cc
│ ├── override_new_delete2.cc
│ ├── BUILD
│ └── operator_new_delete.cc
├── inheritance
│ ├── base_pointer.cc
│ ├── final.cc
│ ├── scope.cc
│ ├── override.cc
│ ├── hiding.cc
│ ├── BUILD
│ ├── virtual.cc
│ ├── pure_virtual_function.cc
│ ├── private_inheritance.cc
│ └── call_virtual_during_ctr copy.cc
├── function
│ ├── generate_main.cc
│ ├── inline.cc
│ ├── all_off_main.cc
│ ├── advanced_transform_main.cc
│ ├── adjacent_diff_main.cc
│ ├── std_function.cc
│ ├── transform.cc
│ ├── copy_if_main.cc
│ ├── lambda_event_class.cc
│ ├── main.cc
│ ├── lambda_main.cc
│ └── filter.cc
├── dynamic_programming
│ ├── memoization.cc
│ ├── fib_table_main.cc
│ ├── coin_tab_main.cc
│ ├── coin_main.cc
│ ├── knap_01_main.cc
│ ├── fib_main.cc
│ ├── lpss_main.cc
│ ├── lscs_table_main.cc
│ ├── fib_memo_main.cc
│ ├── coin_memo_main.cc
│ └── lscs_main.cc
├── iterator
│ ├── istream_iterator.cc
│ ├── BUILD
│ └── main2.cc
├── passing_variables
│ ├── BUILD
│ ├── main.cc
│ └── pass_by_reference_main.cc
├── class
│ ├── struct.cc
│ ├── brackets.cc
│ └── constructor_implicit_default_deleted.cc
├── hash
│ ├── main.cc
│ ├── std_hash_main.cc
│ ├── set_main.cc
│ ├── BUILD
│ └── index_function_main.cc
├── bst
│ ├── BUILD
│ └── main.cc
├── multi_threading
│ ├── main.cc
│ ├── main_vector.cc
│ ├── vector_of_threads_async_main.cc
│ ├── parallel_fib.cc
│ ├── vector_of_threads_main.cc
│ ├── thread_functor.cc
│ └── vector_of_threads_lambda_main.cc
├── modifiers
│ ├── BUILD
│ ├── constants_main.cc
│ └── sizeof_examples_main.cc
└── command_line
│ └── BUILD
├── tree.png
├── .gitignore
├── tests
├── heap_test
│ └── BUILD
├── segment_tree
│ └── BUILD
├── consonant_vowel_imbalance
│ └── BUILD
├── dynamic_programming
│ ├── BUILD
│ ├── lpss_test_table.cc
│ ├── lpss_test_memo.cc
│ └── lpss_test.cc
├── graph
│ ├── adjacency_matrix_test.cc
│ ├── adjacency_vector_of_set_test.cc
│ └── vector_v_vector_pair_e_test.cc
└── vector_union_test.cc
├── .vscode
├── c_cpp_properties.json
└── extensions.json
├── third_party
└── usr_local.BUILD
├── WORKSPACE
├── cpp-template
└── README.md
├── README.md
└── .bazelrc
/src/arrays/text.html:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/lib/inheritance/main.cc:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/string_view/output/string_view_benchmark.csv:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/benchmark/lib.h:
--------------------------------------------------------------------------------
1 | inline void MyInlineFunction();
2 |
--------------------------------------------------------------------------------
/src/lib/segment_tree/segment_tree.cc:
--------------------------------------------------------------------------------
1 | #include "segment_tree.h"
--------------------------------------------------------------------------------
/src/benchmark/lib.cc:
--------------------------------------------------------------------------------
1 | inline void MyInlineFunction(){
2 |
3 | }
--------------------------------------------------------------------------------
/tree.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ourarash/cpp_tour/HEAD/tree.png
--------------------------------------------------------------------------------
/src/lib/consonant_vowel_imbalance/consonant_vowel_imbalance.cc:
--------------------------------------------------------------------------------
1 | #include "consonant_vowel_imbalance.h"
--------------------------------------------------------------------------------
/src/deep_c/33.cc:
--------------------------------------------------------------------------------
1 | #include
2 | int main(void) {
3 | int a = 42;
4 | printf("%d\n", a);
5 | }
--------------------------------------------------------------------------------
/src/stack/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | )
6 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /bazel-Bazel_with_GTest
2 | /bazel-bin
3 | /bazel-genfiles
4 | /bazel-out
5 | /bazel-testlogs
6 | /bazel-template
7 | /bazel-*
8 |
--------------------------------------------------------------------------------
/src/cpp17/Ex01/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 |
3 | cc_binary(
4 | name = "main",
5 | srcs = ["main.cc"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/lib/solution.cc:
--------------------------------------------------------------------------------
1 | #include "solution.h"
2 |
3 | std::string Solution::PrintHelloWorld() {
4 | return "**** Hello World ****";
5 | }
6 |
7 |
--------------------------------------------------------------------------------
/src/cpp20/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 |
3 | cc_binary(
4 | name = "coroutine",
5 | srcs = ["coroutine.cc"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/tbb/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = [""],
6 | )
--------------------------------------------------------------------------------
/src/deep_c/245.cc:
--------------------------------------------------------------------------------
1 | #include
2 | struct X {
3 | int a;
4 | char b;
5 | int c;
6 | };
7 | int main(void) { std::cout << sizeof(X) << std::endl; }
--------------------------------------------------------------------------------
/src/preprocessor/hazf.h:
--------------------------------------------------------------------------------
1 | // #ifndef _MYFILE_H_
2 | // #define _MYFILE_H_
3 |
4 | // // stuff here
5 |
6 | // #endif // _MYFILE_H_
7 |
8 | #pragma once
9 |
--------------------------------------------------------------------------------
/src/explicit/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = [],
6 | )
7 |
8 |
--------------------------------------------------------------------------------
/src/lib/sort/BUILD:
--------------------------------------------------------------------------------
1 | cc_library(
2 | name = "SortLib",
3 | srcs = ["sort.cc"],
4 | hdrs = ["sort.h"],
5 | visibility = ["//visibility:public"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/tuple/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:utility"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/enum/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/hello_world/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
--------------------------------------------------------------------------------
/src/lib/search/BUILD:
--------------------------------------------------------------------------------
1 | cc_library(
2 | name = "SearchLib",
3 | srcs = ["search.cc"],
4 | hdrs = ["search.h"],
5 | visibility = ["//visibility:public"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/nullptr/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
--------------------------------------------------------------------------------
/src/queue/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/string/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/linked_list/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/patterns/proxy/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:utility"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/override/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 |
3 | cc_binary(
4 | name = "main",
5 | srcs = ["main.cc"],
6 | deps = ["//src/lib:SolutionLib"],
7 | )
8 |
--------------------------------------------------------------------------------
/src/patterns/adapter/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:utility"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/patterns/mediator/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:utility"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/patterns/memento/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:utility"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/patterns/observer/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:utility"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/patterns/singleton/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:utility"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/priority_queue/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | # deps = ["//src/lib:SolutionLib"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/sort/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib", "//src/lib/sort:SortLib"],
6 | )
7 |
--------------------------------------------------------------------------------
/src/uniform_initialization/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 |
3 | cc_binary(
4 | name = "main",
5 | srcs = ["main.cc"],
6 | deps = ["//src/lib:SolutionLib"],
7 | )
8 |
--------------------------------------------------------------------------------
/src/vector/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib", "//src/lib:utility",],
6 | )
7 |
--------------------------------------------------------------------------------
/src/list/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib" , "//src/lib:utility",
6 | ],
7 | )
8 |
--------------------------------------------------------------------------------
/src/pointers/pointer_to_void/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib", "//src/lib:utility",],
6 | )
7 |
--------------------------------------------------------------------------------
/src/pointers/void_pointer/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib", "//src/lib:utility",],
6 | )
7 |
--------------------------------------------------------------------------------
/src/moving_average/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 |
3 | cc_binary(
4 | name = "main",
5 | srcs = ["main.cc"],
6 | deps = [
7 | "//src/lib:utility",
8 | ],
9 | )
10 |
--------------------------------------------------------------------------------
/src/heap/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 |
3 | cc_binary(
4 | name = "main",
5 | srcs = ["main.cc"],
6 | deps = ["//src/lib:heap_lib", "//src/lib:utility"],
7 |
8 |
9 | )
10 |
--------------------------------------------------------------------------------
/src/hello_world/main.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | // My first C++ program
5 |
6 | int main() {
7 | std::cout << "**** Hello world!" << std::endl;
8 |
9 | return 0;
10 | }
11 |
--------------------------------------------------------------------------------
/src/const/main.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 | const int i = 1;
7 | const int j = i + 1; // Initializing is ok
8 |
9 | // i++; // Don't change the const!
10 | }
--------------------------------------------------------------------------------
/src/benchmark/output/plus_equal.csv:
--------------------------------------------------------------------------------
1 | name,iterations,real_time,cpu_time,time_unit,bytes_per_second,items_per_second,label,error_occurred,error_message
2 | "BM_Plus",263612775,2.62297,2.59063,ns,,,,,
3 | "BM_PlusEqual",270773135,2.59264,2.56477,ns,,,,,
4 |
--------------------------------------------------------------------------------
/src/questions/sharks/BUILD:
--------------------------------------------------------------------------------
1 | cc_test(
2 | name = "sharks",
3 | srcs = ["sharks.cc"],
4 | copts = ["--std=c++17"],
5 | deps = [
6 | "//src/lib:utility",
7 | "@com_google_googletest//:gtest_main",
8 | ],
9 | )
10 |
--------------------------------------------------------------------------------
/tests/heap_test/BUILD:
--------------------------------------------------------------------------------
1 | cc_test(
2 | name = "heap_test",
3 | srcs = ["heap_test.cc"],
4 | deps = [
5 | "//src/lib:utility",
6 | "//src/lib:heap_lib",
7 | "@com_google_googletest//:gtest_main",
8 | ],
9 | )
10 |
--------------------------------------------------------------------------------
/src/deep_c/main.cc:
--------------------------------------------------------------------------------
1 | #include
2 | struct X {
3 | int a;
4 | char b;
5 | int c;
6 | char* d;
7 | };
8 | int main(void) {
9 | printf("%zu\n", sizeof(int));
10 | printf("%zu\n", sizeof(char));
11 | printf("%zu\n", sizeof(struct X));
12 | }
--------------------------------------------------------------------------------
/src/const/main copy.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | int main() {
6 | const int i = 1;
7 | const int j = i + 1; // Initializing is ok
8 |
9 |
10 |
11 | i++; // Don't change the const!
12 | }
--------------------------------------------------------------------------------
/src/templates/factorial.cc:
--------------------------------------------------------------------------------
1 | #include
2 | template
3 | struct factorial {
4 | enum { value = n * factorial::value };
5 | };
6 |
7 | template <>
8 | struct factorial<0> {
9 | enum { value = 1 };
10 | };
11 |
12 | int main() { return 0; }
13 |
--------------------------------------------------------------------------------
/src/decltype/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib", "//src/lib:utility",],
6 | )
7 | cc_binary(
8 | name = "find_deduced_type",
9 | srcs = ["find_deduced_type.cc"],
10 | )
--------------------------------------------------------------------------------
/src/lib/backtracking/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_library")
2 |
3 | cc_library(
4 | name = "BacktrackingLib",
5 | srcs = ["backtracking.cc"],
6 | hdrs = ["backtracking.h"],
7 | visibility = ["//visibility:public"],
8 | deps = ["//src/lib:utility"],
9 | )
10 |
--------------------------------------------------------------------------------
/src/lib/segment_tree/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_library")
2 |
3 | cc_library(
4 | name = "SegmentTreeLib",
5 | srcs = ["segment_tree.cc"],
6 | hdrs = ["segment_tree.h"],
7 | visibility = ["//visibility:public"],
8 | deps = ["//src/lib:utility"],
9 | )
10 |
--------------------------------------------------------------------------------
/src/move/swap.cc:
--------------------------------------------------------------------------------
1 | #include
2 | template
3 | void SwapMove(T& a, T& b) {
4 | T t(std::move(a));
5 |
6 | a = std::move(b);
7 |
8 | b = std::move(t);
9 | }
10 |
11 | template
12 | void Swap(T& a, T& b) {
13 | T t(a);
14 | a = b;
15 | b = t;
16 | }
--------------------------------------------------------------------------------
/src/sort/main.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 | #include "src/lib/sort/sort.h"
5 | #include "src/lib/utility.h"
6 |
7 | int main() {
8 | std::vector in = {5, 3, 1, 77, -1, 100};
9 | Sort::QuickSort(in);
10 | Print(in);
11 |
12 | return 0;
13 | }
--------------------------------------------------------------------------------
/src/typeid/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
7 |
8 | cc_binary(
9 | name = "2",
10 | srcs = ["2.cc"],
11 | deps = ["//src/lib:SolutionLib"],
12 | )
13 |
14 |
--------------------------------------------------------------------------------
/tests/segment_tree/BUILD:
--------------------------------------------------------------------------------
1 |
2 | cc_test(
3 | name = "segment_tree_test",
4 | srcs = ["segment_tree_test.cc"],
5 | deps = [
6 | "//src/lib/segment_tree:SegmentTreeLib",
7 | "@com_google_googletest//:gtest_main",
8 | "//src/lib:utility",
9 |
10 | ],
11 | )
--------------------------------------------------------------------------------
/src/main/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
7 |
8 | cc_binary(
9 | name = "bishop_moves",
10 | srcs = ["bishop_moves.cc"],
11 | deps = ["//src/lib:SolutionLib"],
12 |
13 | )
--------------------------------------------------------------------------------
/src/smart_pointer/pimple/main.cc:
--------------------------------------------------------------------------------
1 |
2 | //-----------------------------------------------------------------------------
3 | #include "widget.h"
4 |
5 | #include
6 | #include
7 | #include
8 |
9 | int main(int argc, char const *argv[]) {
10 | Widget w;
11 | return 0;
12 | }
13 |
--------------------------------------------------------------------------------
/src/stl_algorithm/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:utility"],
6 | )
7 |
8 | cc_binary(
9 | name = "simple_algorithms",
10 | srcs = ["simple_algorithms.cc"],
11 | deps = ["//src/lib:utility"],
12 | )
13 |
--------------------------------------------------------------------------------
/src/lib/dynamic_programming/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_library")
2 |
3 | cc_library(
4 | name = "DynamicProgrammingLib",
5 | srcs = ["dynamic_programming.cc"],
6 | hdrs = ["dynamic_programming.h"],
7 | visibility = ["//visibility:public"],
8 | deps = ["//src/lib:utility"],
9 | )
10 |
--------------------------------------------------------------------------------
/src/result_of/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 |
3 | cc_binary(
4 | name = "main",
5 | srcs = ["main.cc"],
6 | deps = [
7 | "//src/lib:SolutionLib",
8 | "//src/lib:utility",
9 | ],
10 | )
11 |
12 | cc_binary(
13 | name = "invoke",
14 | srcs = ["invoke.cc"],
15 | )
--------------------------------------------------------------------------------
/src/patterns/mediator/main.cc:
--------------------------------------------------------------------------------
1 | class Button {};
2 | class ListBox {};
3 | class EntryField {};
4 | class Message {};
5 |
6 | class FontDialog {
7 | public:
8 | void OnMessage(Message* msg);
9 |
10 | private:
11 | Button* mOk;
12 | Button* mCancel;
13 | ListBox* mFontList;
14 | EntryField* mFontName;
15 | };
16 |
--------------------------------------------------------------------------------
/src/lib/vector_union.h:
--------------------------------------------------------------------------------
1 | #ifndef VECTOR_UNION_SOLUTION_H
2 | #define VECTOR_UNION_SOLUTION_H
3 |
4 | #include
5 | #include
6 |
7 | class VectorUnionSolution {
8 | public:
9 | std::vector Calculate(const std::vector &a,
10 | const std::vector &b);
11 | };
12 |
13 | #endif
--------------------------------------------------------------------------------
/src/amortization/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
7 |
8 | cc_binary(
9 | name = "binary_counter_main",
10 | srcs = ["binary_counter_main.cc"],
11 | deps = ["//src/lib:SolutionLib"],
12 | )
13 |
14 |
--------------------------------------------------------------------------------
/src/lib/consonant_vowel_imbalance/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_library")
2 |
3 | cc_library(
4 | name = "ConsonantVowelImbalanceLib",
5 | srcs = ["consonant_vowel_imbalance.cc"],
6 | hdrs = ["consonant_vowel_imbalance.h"],
7 | visibility = ["//visibility:public"],
8 | deps = ["//src/lib:utility"],
9 | )
10 |
--------------------------------------------------------------------------------
/src/patterns/factory/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main_factory",
4 | srcs = ["main_factory.cc"],
5 | deps = ["//src/lib:utility"],
6 | )
7 |
8 |
9 | cc_binary(
10 | name = "main_no_factory",
11 | srcs = ["main_no_factory.cc"],
12 | deps = ["//src/lib:utility"],
13 | )
14 |
--------------------------------------------------------------------------------
/src/set_examples/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
7 |
8 |
9 | cc_binary(
10 | name = "vector_union_main",
11 | srcs = ["vector_union_main.cc"],
12 | deps = ["//src/lib:SolutionLib"],
13 | )
14 |
15 |
--------------------------------------------------------------------------------
/src/graph/shortest_path/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = ["//src/lib:SolutionLib"],
6 | )
7 |
8 | cc_binary(
9 | name = "distance_matrix_main",
10 | srcs = ["distance_matrix_main.cc"],
11 | deps = ["//src/lib:SolutionLib"],
12 | )
13 |
14 |
--------------------------------------------------------------------------------
/src/lib/bst.h:
--------------------------------------------------------------------------------
1 | #ifndef BST_TREE_H
2 | #define BST_TREE_H
3 |
4 | #include "tree.h"
5 |
6 | class BST : public Tree {
7 | public:
8 | BST() { root_ = nullptr; }
9 | bool empty();
10 | int size();
11 |
12 | void insert(TreeNode *&root, int v);
13 | TreeNode* search(TreeNode *root, int v);
14 |
15 | TreeNode *root_;
16 | };
17 |
18 | #endif
--------------------------------------------------------------------------------
/tests/consonant_vowel_imbalance/BUILD:
--------------------------------------------------------------------------------
1 | cc_test(
2 | name = "consonant_vowel_imbalance_test",
3 | srcs = ["consonant_vowel_imbalance_test.cc"],
4 | deps = [
5 | "//src/lib:utility",
6 | "//src/lib/consonant_vowel_imbalance:ConsonantVowelImbalanceLib",
7 | "@com_google_googletest//:gtest_main",
8 | ],
9 | )
10 |
--------------------------------------------------------------------------------
/src/opreators/bool_main.cc:
--------------------------------------------------------------------------------
1 | #include "src/lib/utility.h"
2 | #include
3 | #include
4 |
5 | int main() {
6 |
7 | bool t = true;
8 | bool f = false;
9 | bool c = (1 == 5);
10 |
11 | std::cout << "t: " << t << std::endl;
12 | std::cout << "f: " << f << std::endl;
13 | std::cout << "c: " << c << std::endl;
14 |
15 | return 0;
16 | }
--------------------------------------------------------------------------------
/src/preprocessor/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 | cc_binary(
3 | name = "main",
4 | srcs = ["main.cc"],
5 | deps = [],
6 | )
7 |
8 | cc_binary(
9 | name = "constexpr",
10 | srcs = ["constexpr.cc"],
11 | deps = [],
12 | )
13 | cc_binary(
14 | name = "constexpr_class",
15 | srcs = ["constexpr_class.cc"],
16 | )
17 |
18 |
--------------------------------------------------------------------------------
/src/deep_c/379.cc:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | struct A {
4 | A() { puts("A()"); }
5 | A(int v) { puts("A(int)"); }
6 | ~A() { puts("~A()"); }
7 | };
8 | struct X {
9 | X(int v) { a = v; }
10 | X(long v) : a(v) {}
11 | A a;
12 | };
13 | int main() {
14 | puts("bad style");
15 | { X slow(int(2)); }
16 | puts("good style");
17 | { X fast(long(2)); }
18 | }
--------------------------------------------------------------------------------
/src/uniform_initialization/initializer_list/BUILD:
--------------------------------------------------------------------------------
1 | load("@rules_cc//cc:defs.bzl", "cc_binary")
2 |
3 | cc_binary(
4 | name = "main",
5 | srcs = ["main.cc"],
6 | deps = ["//src/lib:SolutionLib"],
7 | )
8 |
9 |
10 | cc_binary(
11 | name = "explicit_constructor",
12 | srcs = ["explicit_constructor.cc"],
13 | deps = ["//src/lib:SolutionLib"],
14 | )
15 |
--------------------------------------------------------------------------------
/src/random/rand_main.cc:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include "src/lib/solution.h"
5 |
6 | int main() {
7 | srand(2);
8 |
9 | // Generate random number between 1 and 10
10 | for (size_t i = 0; i < 10; i++) {
11 | auto random_number = rand() % 10 + 1;
12 | std::cout << "random_number: " << random_number << std::endl;
13 | }
14 | return 0;
15 | }
--------------------------------------------------------------------------------
/src/arrays/dangerous_main.cc:
--------------------------------------------------------------------------------
1 | #include "src/lib/utility.h"
2 | #include
3 | #include
4 |
5 | struct Person {
6 | std::string first_name;
7 | std::string last_name;
8 | int age;
9 | };
10 |
11 | int main() {
12 |
13 | // Index out of bound
14 | int arr[4];
15 |
16 | for (int i = 0; i < 10; i++) {
17 | arr[i] = 0;
18 | }
19 |
20 | return 0;
21 | }
--------------------------------------------------------------------------------
/src/cpp17/file_system3.cc:
--------------------------------------------------------------------------------
1 |
2 | #include
3 | #include
4 |
5 | namespace fs = std::filesystem;
6 |
7 | int main() {
8 | fs::path p5 = "/usr/a/b/c";
9 | fs::path p6 = "/usr/a/b/c";
10 | assert(p5 == p6);
11 | assert(p5.compare(p6) == 0);
12 |
13 | p5 = "/usr/a/b/c";
14 | p6 = "/usr/a/b/c/d";
15 | assert(p5 < p6);
16 | assert(p5.compare(p6) < 0);
17 | }
--------------------------------------------------------------------------------
/src/graph/pointer_main.cc:
--------------------------------------------------------------------------------
1 | #include "src/lib/graph/pointer.h"
2 | #include
3 | #include
4 | #include