Meeting 31 August 2017
VS2017 + modules
- Modules +
module
identifier => failed build - Compiler:
msvc140
vs.msvc141
- Boost: no more
std::unary_function
andstd::binary_function
(fixed in 1.64) - IncrediBuild support for modules: ???
How to use the C++ Core Guidelines Checker outside of Visual Studio
- VS2017.3
1<PropertyGroup>
2 <EnableCppCoreCheck>true</EnableCppCoreCheck>
3 <CodeAnalysisRuleSet>
4 CppCoreCheckRules.ruleset
5 </CodeAnalysisRuleSet>
6 <RunCodeAnalysis>true</RunCodeAnalysis>
7</PropertyGroup>
msbuild /p:EnableCppCoreCheck=true
/p:RunCodeAnalysis=true
/p:CodeAnalysisRuleSet=CppCoreCheckRules.ruleset ...
Software development 450 words per minute
- Post
- Uses Notepad++ and Intellij IDEA
- Sublime Text: not accessible
- NVDA screen reader – open-source, Windows-only
- VoiceOver – Mac and iOS
- Orca – Gnome
How a blind person uses Visual Studio
Functional data structures in C++ by Bartosz Milewski, C++Now 2014
- GitHub
- Blog post
- C++ (naive implementation) vs. Haskell is 1000x slower:
- heap allocation: big blobs vs. small chunks
- smart pointers vs. GC
- native (non-pooled) threads vs. lightweight threads
- sub-optimal synchronisation
- not using move semantics properly
std::function
allocates
David Stone - Writing Robust Code - Meeting C++ 2014
MTuner
MTuner is a C/C++ memory profiler and memory leak finder for Windows, PS4, PS3, etc.
MTuner utilizes a novel approach to memory profiling and analysis, keeping entire time-based history of memory operations. This gives an unique insight in memory related behavior of your software by making queries over the entire data set.
Licence: BSD-2
Visual C++ for Linux Development with CMake
- Requires VS 2017 15.4
pybind11
- Seamless operability between C++11 and Python
- Header only
- Exposes C++ types in Python and vice versa, mainly to create Python bindings of existing C++ code
- Similar to Boost.Python library
C++17: file system
- Post by Bartlomiej (Bartek) Filipek
- Reddit thread
C++ documentation generators
- Reddit thread
- Doxygen (sample)
- Doxypress
- Doxygen + Sphinx + Breathe (sample1, sample2)
- Standardese (sample)
- Robert Ramey, How to Write Effective Documentation for C++ Libraries with Minimal Effort, CppCon 2017
C++/WinRT
- Modern C++ Blog by Kenny Kerr
- GitHub
- C++17
- Coroutines
- Clang support
[[deprecated]]
- Simplified ABI interop
- “Optimized agility implementation”???
IAgileObject
:-|
libnyquist: audio decoding library
- GitHub
- C++11
- Ogg Vorbis, FLAC, Wave, MIDI, MOD etc.
- BSD licence
FlaggedT: type level flagging
Flagged<T>
offers multiple wrapper types which allow you to add properties to your variables at type level. The wrapped types can still be used as the inner type, thanks to operator overloading.
- GitHub
- MIT licence
- Single header
Top 20 C++ multithreading mistakes and how to avoid them
Honestly disappointed that list was in order. What a missed opportunity.
HexType: Efficient Detection of Type Confusion Errors for C++
- Run-time defences against type confusion errors (bad casts)
- Less run-time overhead and better detection than TypeSan, CaVer, UBSan
- LLVM-based
Custom type traits
1// only WANTED type available
2template<typename WANTED, typename...>
3struct can_be_used_as : std::true_type
4{};
5
6// Processes all given types
7template<typename WANTED,
8 typename HEAD,
9 typename... TAIL>
10struct can_be_used_as<WANTED, HEAD, TAIL...>
11 : std::integral_constant<
12 bool,
13 (std::is_same<WANTED,HEAD>{} ||
14 std::is_base_of<WANTED,HEAD>{} ||
15 std::is_convertible<HEAD,WANTED>{}) &&
16 can_be_used_as<WANTED, TAIL...>{}>
17{};
Simplify your type traits with C++14 variable templates
Before:
1template <typename T>
2struct is_float {
3 static constexpr bool value =
4 std::is_same<T, float>::value;
5};
or
1template <typename T>
2using is_float =
3std::integral_constant<bool,
4 std::is_same<T, float>::value>;
Usage:
1template <typename T>
2void test(T t){
3 if (is_float<T>::value){
4 std::cout << "I'm a float" << std::endl;
5 } else {
6 std::cout << "I'm not a float" << std::endl;
7 }
8}
After:
1template <typename T>
2constexpr is_float = std::is_same_v<T, float>;
Usage:
1template <typename T>
2void test(T t){
3 if (is_float<T>){
4 std::cout << "I'm a float" << std::endl;
5 } else {
6 std::cout << "I'm not a float" << std::endl;
7 }
8}
Metabench: compile-time benchmarks
- Author: Louis Dionne
- GitHub
- A single CMake module
- Requires CMake 3.1 and Ruby 2.1
- Works with CMake and Ninja
- Boost licence
Ignore std::bad_alloc?
On Windows, thrown exceptions are copied onto the stack. Destructors and catch blocks are “called” with all of the previous function frames still on the stack. Only when the exception is handled is the stack pointer popped. This has the unfortunate side effect that rethrowing an exception in a deep call stack can cause stack exhaustion.
With the Itanium ABI (Linux, Mac, etc.), the exception is pretty much forced to be on the heap. The compiler will emit calls to void *__cxa_allocate_exception(size_t)
and void __cxa_free_exception(void *)
. However, the implementations of those functions aren’t required to use new
. The LLVM implementation uses malloc
, and if that fails, it goes to an emergency fallback store of 512 bytes.
If you’re running on Linux then all memory allocations where the size is less than the physical ram succeed because it uses overcommit. All of them, whether there’s enough available memory left or not. Your application will just crash when you try to use it.