Skip to content

Instantly share code, notes, and snippets.

@LegalizeAdulthood
LegalizeAdulthood / type_traits.cpp
Created November 5, 2015 15:42
C++ <type_traits> koans
#include "type_traits.h"
#include <type_traits>
// In each test, replace XXX with syntax that passes the test.
BOOST_AUTO_TEST_CASE(is_void)
{
BOOST_REQUIRE_EQUAL(true, std::is_void<XXX>::value);
std::is_void<XXX> val;
BOOST_REQUIRE_EQUAL(true, static_cast<bool>(val));
@LegalizeAdulthood
LegalizeAdulthood / ClangContributions.md
Last active May 22, 2024 18:08
My Clang Contributions

My Clang Contributions

  • clang tooling library:
    • AST matchers:
      • extend hasType to work with TypedefDecl nodes
      • add functionProtoType matcher for matching FunctionProtoType nodes
      • extend parameterCountIs matcher to FunctionProtoType nodes
  • clang-tidy checks:
  • modernize-raw-string-literal converts string literals with escaped characters to raw string literals
TEST( Foo, foo )
{
int failures = 0;
for (int i = 0; i < 50; ++i) {
EXPECT_TRUE( i % 2 == 0 ) << ([&failures]() { ++failures; return ""; })();
}
if (failures > 0) {
std::cout << "There were " << failures << " failures.\n";
}
}
@LegalizeAdulthood
LegalizeAdulthood / Outline.md
Last active November 15, 2017 22:50
Compile-Time Programming Explained

Outline

@LegalizeAdulthood
LegalizeAdulthood / json.cpp
Created November 15, 2017 22:49
Compile-time JSON example
constexpr auto jsv = R"({
"feature-x-enabled": true,
"value-of-y": 1729,
"z-options": {
"a": null,
"b": "220 and 284",
"c": [ 6, 28, 496 ]
}
})"_json;
@LegalizeAdulthood
LegalizeAdulthood / Outline.md
Last active December 14, 2017 18:54
Embedded Development with Kvasir

Refresher of Embedded Development

  • Characteristics of an embedded environment
    • Bare metal interaction with hardware
    • No operating system
    • No virtual memory
    • No C/C++ runtime
  • No RTTI
@LegalizeAdulthood
LegalizeAdulthood / Outline.md
Last active February 7, 2018 22:41
Give Your Old Code Some New Love

Case Study

  • Our case study is the open source fractal generator Iterated Dynamics, a fork of FRACTINT.
  • This is a 30 year old code base that started as a 16-bit MS-DOS program written in C and 16-bit x86 assembly.
  • The code base has contributions from many, many authors over the years.
  • Source formatting and identifier conventions are varied due to the large number of authors.
  • Source code organization has been tortured by the constraints of early MS-DOS programs operating in a limited amount of physical memory and the use of overlays.
  • Conditional compilation was sprinkled throughout to enable various debugging facilities or experiments in alternative implementations.
  • As C does not have inline functions, there are some places that heavily use preprocessor macros.
  • Some of the functions are [exceedingly long*](https://github.com/LegalizeAdulthood
@LegalizeAdulthood
LegalizeAdulthood / HowToSonarQube.md
Created May 8, 2019 21:55
SonarQube Configuration for C++ Projects

SonarQube Configuration for C++ Projects

  1. Download SonarQube from SonarQube.org.
  2. Unpack the distribution.
  3. Download the C++ community plugin.
  4. Install the plugin using these instructions.
  5. Run bin\windows-x86-64\StartSonar.bat to start the server.
  6. Wait for the server to output the message SonarQube is up.
  7. Browse to http://localhost:9000 and login with admin/admin.
  8. Create a project by following the built-in tutorial.
  9. Configure the scanner for C++
@LegalizeAdulthood
LegalizeAdulthood / SpaceshipOperator.txt
Last active January 4, 2022 03:04
A counterintuitive breaking change related to new comparisons C++17 vs. C++20
comp.lang.c++ #1074341 (1)
From: Andrey Tarasevich <[email protected]>
[1] A counterintuitive breaking change related to new comparisons
Date: Mon Jan 03 10:48:42 MST 2022
Lines: 42
A colleague discovered that switching from `-stc=c++17` to `-std=c++20`
in their project resulted in a different behavior from some associative
containers. A bit of research allowed to narrow down the culprit to what
can be demonstrated by the following minimalist example
@LegalizeAdulthood
LegalizeAdulthood / PortingFromMFCToWxWidgets.md
Last active July 19, 2024 08:58
Porting from MFC to wxWidgets