Skip to content

Instantly share code, notes, and snippets.

@LegalizeAdulthood
LegalizeAdulthood / Outline.md
Last active November 15, 2017 22:50
Compile-Time Programming Explained

Outline

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 / 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
@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));