Skip to content

Instantly share code, notes, and snippets.

View MATRIXKOO's full-sized avatar
Focusing

M4tr1xt4ng MATRIXKOO

Focusing
View GitHub Profile
@s9w
s9w / gist:ad9b1dd1ea6fb17e956559c8b352e246
Last active June 22, 2024 13:35
Potential issue with C++20's initialization change

Potential issue with C++20's initialization change

C++20 takes yet another swing at its infamous initialization rules. The players involved this time are Aggregate initialization (type a{1, 2, 3}) and direct initialization (type a(1, 2, 3)). A common pitfall with aggregate init is:

std::vector<int> vec0(5, 9); // 9, 9, 9, 9, 9
std::vector<int> vec1{5, 9}; // 5, 9

So if you don't know what you're doing, {} is potentially dangerous to use with types that might have both "real" constructors and such with std::initializer_list. If you had your head in the sand for 10 11 years and always used () then you never were in danger.

option (FORCE_COLORED_OUTPUT "Always produce ANSI-colored output (GNU/Clang only)." FALSE)if (${FORCE_COLORED_OUTPUT})
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
add_compile_options (-fdiagnostics-color=always)
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options (-fcolor-diagnostics)
endif ()
endif ()
@MaskRay
MaskRay / implement-an-elf-linker.md
Last active April 12, 2024 07:27
Implement an ELF linker
theme class highlighter fonts
default
text-center
MaskRay
sans serif mono
sans-serif
serif
monospace
@gtors
gtors / gist:effe8eef7dbe7052b22a009f3c7fc434
Created December 10, 2018 12:57
Makefile -> compilation_commands.json