Collaborative Collection of C++ Best Practices.

Overview
Issues
  • About

    About "t_" prefix

    Why we should use "t_" prefix for function parameters? What is the practical sense? I think it's just difficult to read. The function parameters should not be prefixed.

    https://github.com/lefticus/cppbestpractices/blob/master/03-Style.md#distinguish-function-parameters

    opened by AlekseyDurachenko 19
  • Allocation performance with limited variable scope

    Allocation performance with limited variable scope

    So this is mostly from a discussion perspective. I'm not experienced when it comes to C++, but I'm thinking about this discussion of limited scope.

    I'm mostly concerned that we might spend too much time initializing objects. Assume I have a large object (say an image) that I want to run an operation on to get some value, and I further run several operations per picture (running different sorts of filters, etc. etc.) each of these operations needing their own copy of the image that they run their operations on. Further, all of this happens several times a second, since it comes from a video stream.

    I would have some function treat_frame() working with each frame, and have that function call functions for each operation. Wouldn't limiting the scope of the working objects (having them local to each function) cause constructors and destructors for these quite large objects several times every second? From my perspective it seems wiser to allocate them once outside the scope of the loop, and then have them use the same memory over and over.

    Not sure how far this goes though. I did something like the above in a university project, and in profiling it turned out a lot of time was spent in constructors and allocators. Not sure how it would be with something like the example code. Like, would the constructor get invoked every iteration in the below code?

    // Good Idea
    for (int i = 0; i < 15; ++i)
    {
      MyObject obj(i);
      // do something with obj
    }
    
    opened by rubicus 11
  • Addition for section

    Addition for section "Avoid Raw Memory Access"

    In section "Avoid Raw Memory Access" using of std::unique_ptr can be added for arrays:

    auto my_data = std::make_unique<MyDataClass>(128);
    
    opened by theta682 8
  • best practice for getter

    best practice for getter

    In the safety module, there is an example recommending using const to indicate an immutable getter method: std::string get_value() const { /* etc */ }

    However, I think that best practices actually recommend going slightly further by also returning a const reference. Like this: std::string const &get_value() const { /* etc */ }

    Can anyone confirm or deny this practice? Is it a best practice?

    opened by sbowman-mitre 7
  • Page references?

    Page references?

    To facilitate navigation of this document directly, perhaps we should add "previous" "next" and "Table of Contents" links to the top and bottom of each page?

    opened by aravol 5
  • Comment out code with

    Comment out code with "#if 0"

    Instead of commenting out the code with /* */ you can use:

    #if 0
    void function_f(int param)
    {
      (void)param;
    }
    #endif
    

    In this case you can nest such commented out parts. Moreover, syntax highlighting still work in some IDEs.

    opened by theta682 4
  • use ? operator

    use ? operator

    // Better Idea
    const std::string somevalue = [&](){
        if (somecase()) {
          return "Value A";
        } else {
          return "Value B";
        }
      }();
    
    // Better Idea
    const std::string somevalue =  somecase()) ? "Value A" :  "Value B";
          return "Value A";
    
    opened by robertramey 4
  • "double typically faster than float"

    It is stated here that

    Operations on doubles are typically faster than floats.

    I can not reproduce this. For my tests, doing math on floats and doubles is equally fast if SSE is not considered. I would even have expected that floats would be faster due to memory bandwidth but I am having trouble testing that since gcc keeps autovectorizing my code.

    Anyway, can anyone confirm or deny the statement that doubles are faster than floats anywhere?

    opened by 983 3
  • Precompiled Header

    Precompiled Header

    I started to fill the section about precompiled headers with some general information and some links to manuals for the common compiler. Any additional suggestions?

    opened by rob100 3
  • Additional motivation i++ vs ++i

    Additional motivation i++ vs ++i

    Very glad to hear that pre-increment should be preferred. However, your reasons are easily debunked in modern times where compilers will optimize both versions to the same machine level instructions. However, this argument breaks as soon as more complicated types are used: iterators. Your example uses plain old ints, but it would be clearer if you elaborated a little by using (user-defined) classes that overload ++.

    opened by jorenheit 3
  • Unclear mention of -Weffc++ in

    Unclear mention of -Weffc++ in "Use the tools available"

    In the Use the tools available section it is recommended to enable the flag -Wnon-virtual-dtor, and there is a note that says -Weffc++ warning mode can be too noisy, but if it works for your project, use it also. however, according to clang's documentation, these two flags are synonyms https://clang.llvm.org/docs/DiagnosticsReference.html#weffc

    opened by IgnacioJPickering 2
  • Clarify that marking certain member variables const can hinder performance

    Clarify that marking certain member variables const can hinder performance

    In the 03-Style document, I read the following sentence:

    If the member variable is not expected to change after the initialization, then mark it const.

    However, we know that if, for example, we mark a container as const, we prevent it from being moved, possibly hindering performance. Marking fields as const is useful to enforce invariants; however, it "interferes" with performance. If both const correctness and performance are important, one could leave the field non-const, make it private and define a field getter.

    opened by andreastedile 0
  • Add note about VS2022's treat angle brackets as external feature

    Add note about VS2022's treat angle brackets as external feature

    This is a really good way to temporarily develop with /Wall enabled, then switching back to /W4 after fixing all of the extra warnings.

    You can also disable other types of diagnostics in STL headers, e.g. /external:templates-, /analyze:external-.

    opened by ifarbod 0
  • 02-Use_the_Tools_Available.md -> cmake/coite ist deprecated

    02-Use_the_Tools_Available.md -> cmake/coite ist deprecated

    coitre declares itself as depreacted:

    from https://github.com/sakra/cotire/:

    The functionality provided by cotire has been superseded by features added to CMake 3.16. Support for pre-compiling and unity builds is now built into CMake. Thus, there will not be any further updates or support for this project.

    opened by jolz 0
  • MSVC /Wall is not unusable because of standard library headers

    MSVC /Wall is not unusable because of standard library headers

    The current wording reads "/Wall - Also warns on files included from the standard library, so it's not very useful and creates too many extra warnings." – this reason does not seem to hold, because /external (i.e. /external:anglebrackets) exists and is effective in preventing /Wall warnings in the standard headers too.

    A better reason to avoid /Wall would be a large number of informational diagnostics (i.e. https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-1-c4711?view=msvc-170) - but then again, these can be disabled individually.

    opened by laurynas-biveinis 1
  • Source control tools are not source control hosing services

    Source control tools are not source control hosing services

    It is stated:

    Source control is an absolute necessity for any software development project. If you are not using one yet, start using one.

    Which is true, but then there is a list of source control hosting services, which are not the same thing.

    opened by Klaim 0
  • First discuss runtime performance

    First discuss runtime performance

    This moves the runtime performance discussion before the build time discussion

    It was kind of surprising to discuss build-time performance first, something that most developers don't need to be worried about, especially now that C++20 has modules.

    opened by aminya 0
Releases(v1.0.0)
Owner
Jason Turner
Host of C++ Weekly YouTube series, co-host of CppCast C++ podcast.
Jason Turner
Fast C++ container combining the best features of std::vector and std::deque

veque The double-ended vector A very fast C++17 container combining the best features of std::vector and std::deque "In Most Cases, Prefer Using deque

null 97 May 4, 2022
Minimal Linux Live (MLL) is a tiny educational Linux distribution, which is designed to be built from scratch by using a collection of automated shell scripts. Minimal Linux Live offers a core environment with just the Linux kernel, GNU C library, and Busybox userland utilities.

Minimal Linux Live (MLL) is a tiny educational Linux distribution, which is designed to be built from scratch by using a collection of automated shell scripts. Minimal Linux Live offers a core environment with just the Linux kernel, GNU C library, and Busybox userland utilities.

John Davidson 1.3k Jun 20, 2022
A collection of 1000 C++ Programs

⭐ ⭐ ⭐ 500-CPP ⭐ ⭐ ⭐ A collection of 500 C++ Programs CONTENTS Sl. No. Program Title Link 1 Sum of array elements https://github.com/MainakRepositor/10

MAINAK CHAUDHURI 22 May 30, 2022
Teach the C programming language using a collection of super beginner friendly tutorials and challenges.

TeachMeCLikeIm5 You are welcome to contribute to this repo. See the CONTRIBUTING.md for more info ?? About this repo ?? A collection of super beginner

inspirezonetech 10 Feb 4, 2022
Collection of C99 dynamic array implementations

darc darc stands for Dynamic ARray Collection. This repo hosts 3 type-generic C99 implementations : mga (Macro Generated Array) type-safe 0-cost abstr

A.P. Jo. 11 May 5, 2022
A collection of packages for Ultimate++ framework.

upp-components This repository contains supplementary general-purpose packages for Ultimate++, a C++ cross-platform rapid application development fram

İsmail Yılmaz 34 Feb 8, 2022
The C++ Core Guidelines are a set of tried-and-true guidelines, rules, and best practices about coding in C++

The C++ Core Guidelines are a collaborative effort led by Bjarne Stroustrup, much like the C++ language itself. They are the result of many person-years of discussion and design across a number of organizations. Their design encourages general applicability and broad adoption but they can be freely copied and modified to meet your organization's needs.

Standard C++ Foundation 34.4k Jun 27, 2022
Best practices, conventions, and tricks for ROS. Do you want to become a robotics master? Then consider graduating or working at the Robotics Systems Lab at ETH in Zürich!

ROS Best Practices, Conventions and Tricks Best practices for ROS2 in the making. See the Foxy branch in the meanwhile. This is a loose collection of

Robotic Systems Lab - Legged Robotics at ETH Zürich 1.1k Jun 24, 2022
Example library that shows best practices and proper usage of CMake by using targets

Modern CMake Sample Sample project that shows proper modern CMake usage on a dummy library and an executable that uses it. Accompanying code to my blo

Pablo Arias 566 Jun 21, 2022
BEST Robotics Code for BEST Robotics - RedShift Robotics

RedShift_BEST_2021 BEST Robotics Code for BEST Robotics - RedShift Robotics Sourced From RedShift Robotics Engineering Notebook: Software Design Every

null 1 Nov 6, 2021
A C library for product recommendations/suggestions using collaborative filtering (CF)

Recommender A C library for product recommendations/suggestions using collaborative filtering (CF). Recommender analyzes the feedback of some users (i

Ghassen Hamrouni 249 Jun 13, 2022
A C library for product recommendations/suggestions using collaborative filtering (CF)

Recommender A C library for product recommendations/suggestions using collaborative filtering (CF). Recommender analyzes the feedback of some users (i

Ghassen Hamrouni 249 Jun 13, 2022
CollabFuzz: A Framework for Collaborative Fuzzing

Collaborative Fuzzing Design In this cooperative framework, the fuzzers collaborate using a centralized scheduler.

VUSec 60 Jun 15, 2022
Collaborative and comprehensive testing for libft project

first Draft Collaborate on libft tests, everything here is open to suggestions This is hopefully a way to both practice git collaboration and creat a

null 4 Nov 24, 2021
C++ implementations of well-known (and some rare) algorithms, while following good software development practices

ProAlgos: C++ This project is focused on implementing algorithms and data structures in C++, while following good software engineering practices, such

ProAlgos 469 Jun 17, 2022
A collection of services with great free tiers for developers on a budget. Sponsored by Mockoon, the best mock API tool.

A collection of services with great free tiers for developers on a budget. Sponsored by Mockoon, the best mock API tool.

Guillaume 11.1k Jun 27, 2022
A personal collection of Windows CVE I have turned in to exploit source, as well as a collection of payloads I've written to be used in conjunction with these exploits.

This repository contains a personal collection of Windows CVE I have turned in to exploit source, as well as a collection of payloads I've written to

null 76 Jun 22, 2022
Screens options data to find the best options to sell for theta-gangers

Robinhood-options-screener Screens options data to find the best options to sell for theta-gangers, works for cash-secured-puts and covered-calls. Get

null 24 Jun 7, 2022
A local DNS server to obtain the fastest website IP for the best Internet experience

A local DNS server to obtain the fastest website IP for the best Internet experience

Nick Peng 5k Jun 26, 2022
Best Method to get Globally Banned from the cfx.re community

Lua-Executor Best Method to get Globally Banned from the cfx.re community Since cheaters have been going crazy selling 'their' hacks, and often gets d

Scopes 6 Jan 31, 2022
I'm trying to make the best coin possible

AZZYCOIN name: Azzycoin ticker: AZY maturity: 100 max supply: 420,480,000 p2p port: 26900 rpc port: 27001 halving: 4,204,800 block time: 30 sec diffic

null 1 Nov 4, 2021
A late bound, hope-for-the-best dyld shared cache extractor

yolo_dsc A late bound, hope-for-the-best dyld shared cache extractor why? There are other dsc_extract utilities. They usually require some combination

Rick Mark 14 Mar 17, 2022
✨ Your best friend when it comes to making your output beautiful ✨

?? Fadey ✨ Your best friend when it comes to making your output beautiful ✨ ?? Content: About Requirements Installation Features Performance Shoutout

Fluffy 3 Nov 29, 2021
The Best and Highest-Leveled and Newest bingding for MiMalloc Ever Existed in Rust

The Best and Highest-Leveled and Newest bingding for MiMalloc Ever Existed in Rust mimalloc 1.7.2 stable Why create this in repo https://github.com/pu

LemonHX 27 Jun 15, 2022
Software for the best kitchen timer.

kitchen timer The summer of 2021 I finally got fed up with my crappy ikea kitchen timer and decided to build my own. You can find a build log in this

Martin Jonasson 27 Apr 5, 2022
SIMULATeQCD is a multi-GPU Lattice QCD framework that makes it simple and easy for physicists to implement lattice QCD formulas while still providing the best possible performance.

SIMULATeQCD a SImple MUlti-GPU LATtice code for QCD calculations SIMULATeQCD is a multi-GPU Lattice QCD framework that makes it simple and easy for ph

null 10 Apr 23, 2022
A python package to provide you with many useful tools for osu! servers, written in C++ for the best speeds possible.

pysu_bindings A python package to provide you with many useful tools for osu! servers, written in C++ for the best speeds possible. What? As most peop

James 2 Nov 29, 2021
ADD YOUR BEST PROJECT & CONTIBUTE TO OPEN WORLD, MAKE GENUINE PR TO BE MERGED.

Hacktoberfest 2021 Kindly maintain patience, our team will accept every valid Pull Request and will merge it in main branch!!! Link To HacktoberFest 2

null 3 Oct 19, 2021
Fast C++ container combining the best features of std::vector and std::deque

veque The double-ended vector A very fast C++17 container combining the best features of std::vector and std::deque "In Most Cases, Prefer Using deque

null 97 May 4, 2022