Title: Theory / Important / Chrome / Style
On every note of this deck, unless a note says otherwise:
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md
Context: Chrome
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md

Extension: _unittest.cc
Means: unit test files
Other fields (not shown on cards):
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md

Extension: _browsertest.cc
Means: browser test files
Other fields (not shown on cards):
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md

Question: Where should * be put in a variable declaration
Answer: Near the type, and not near the variable name.
E.g.
int* foo

Question: Where should & be put in a variable declaration
Answer: Near the type, and not near the variable name.
E.g.
int& foo

Instruction: testonly=true
Effect: The class can only be used in test
Language: GN
Context: Chrome

Instruction: returnType fooForTesting() { ... }
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md
Meaning: Same declaration as standard c++, but can only be used in test
Language: C++
Context: Chrome

Instruction: class FOO_EXPORT Foo {
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md
Meaning: Foo is exported outside of a shared library/DLL
Language: C++
Context: Chrome
Similar to: class Foo {

Instruction: FOO_EXPORT Foo& method_name(...);
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md
Meaning: method_name is exported outside of shared library/DLL
Language: C++
Context: Chrome

Instruction: DVLOG(i)
Language: C++
Context: Chrome
Returns: An out-channel accepting log at level i

Fla: --v=n
Effect: print all logs at level n or lower
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md
Context: Chrome

Fla: --vmodule=pattern=n
Effect: print all logs from files satisfying pattern, at level n or lower
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md
Context: Chrome

Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++.md
Syntactic sugar: --vmodule=pattern_1=n_1,...,pattern_m,n_m
Implementation: --vmodule=pattern_1=n_1
...
--vmodule=pattern_m=n_m
Language: Objective-C
Context: Chrome

Instruction: defined(OS_foo)
Language: Objective-C
Context: Chrome
Returns: macro that holds iff the os is foo

Question: How to include files for a OS specifically
Answer: Import files used for all OS first.
Then group by OS. Uses
#if defined(OS_foo)
And put here the files for OS foo. Uses the same order as for general import
#elif
...
#endif

Question: What type to uses for object size
Answer: size_t

Question: What type to uses for allocation size
Answer: size_t

Question: What type to uses for object counts
Answer: size_t

Question: What type to uses for array offsets
Answer: size_t

Question: What type to uses for pointer offsets
Answer: size_t

Question: What type to uses for vector indices
Answer: size_t

Question: What to do if an implementation would be less efficient if using size_t instead of another type?
Answer: Use size_t in public facing interface and convert to efficient representation internally

Question: What type to use when sending value through network
Answer: Use an explicitly-sized type

Question: What type to use when sending accross process boundaries
Answer: Use an explicitly-sized type

Question: What type to use when a function takes a value t of type T and do not modify its ownership
Answer: Use type T* unless impossible

Question: What type to use when a function takes a value t of type T and takes its ownership that is not refcounted
Answer: Use type std::unique_ptr<T>

Question: What type to use when a function takes a value t of type T and takes its ownership that is refcounted
Answer: Use type scoped_refptr<T>

Question: What type to use when a function returns a value t of type T, and the caller do not take ownership
Answer: Use type T*

Question: What type to use when a function returns a value t of type T, and the caller takes ownership
Answer: Use type std::unique_ptr<T> or scoped_refptr<T>

Instruction: CHECK(foo)
Effect: Crash the program if foo is false
Language: Objective-C
Context: Chrome

Instruction: DCHECK(foo)
Effect: Crash the program if foo is false and compiled with DCHECK_IS_ON
Language: Objective-C
Context: Chrome

Instruction: NOTREACHED()
Effect: Crash the program when reached if compiled with DCHECK_IS_ON
Language: Objective-C
Context: Chrome

Question: How to indicate pre condition in code
Answer: uses DCHECK (i.e. crash in debug mode)

Question: How to indicate post condition in code
Answer: uses DCHECK (i.e. crash in debug mode)

Question: How to deal with a condition which, if false, would be a security vulnerability
Answer: If possible, halt what can be halted to remove the risk
Answer2: otherwise uses CHECK(condition)

Question: If you need to crash release build to figure out which assertion is failing, how to do so
Answer: Use CHECK in release build. Move to DCHECK as soon as the issue is corrected

Question: How to deal with assertion regarding null pointer dereferencing
Answer: no need to use CHECK or DCHECK, compiler flag ensure that it is not assumed that pointers at not null
Answer2: Uses DCHECK as it may help with debugging
Answer3: Use a reference if a pointer can not be null

Question: What file encoding uses chrome
Answer: UTF-8

Question: What end of line symbol uses chrome
Answer: LF

Question: Where should unit test be placed
Answer: In the same directory than the functionality they're testing

Question: Where should performance test be placed
Answer: In the same directory than the functionality they're testing

Question: Which kind of constructor to use for simple task
Answer: Use implicit constructor with
type name = {values_copied_in_object}
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++-dos-and-donts.md

Question: Which kind of constructor to use for complex task
Answer: Use explicit constructor with
type name(some_logic_parameter)
Page: https://chromium.googlesource.com/chromium/src/+/HEAD/styleguide/c++/c++-dos-and-donts.md