Skip to content

Instantly share code, notes, and snippets.

@jonwis
jonwis / std_lazy.h
Created November 23, 2024 07:52
Lazy C++ type suggestion
// https://godbolt.org/z/xnd359j99
#include <optional>
#include <mutex>
#include <functional>
template<typename T> struct default_lazy_init {
T operator()() const {
return T{};
}
@jonwis
jonwis / test_lookups.cpp
Created December 9, 2024 07:29
Vector map unordered set test
// ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
//
#include <iostream>
#include <map>
#include <chrono>
#include <unordered_map>
#include <array>
#include <string>
#include <functional>
@jonwis
jonwis / sample_header.hxx
Created December 9, 2024 20:02
A model for free-threaded properties in a C++/WinRT Object
#include <winrt/base.h>
/* Assume this type:
runtimeclass Foo {
String Name;
UInt32 Id { get; };
Foo[] GetMoreFoos();
}
@jonwis
jonwis / deploy_wasdk.py
Created March 17, 2025 06:13
Deploy WASDK with python
import os
import sys
import subprocess
import urllib.request
import argparse
from pathlib import Path
wasdk = {
"name": "Microsoft.WindowsAppSDK",
"version": "1.7.250127003-experimental3",
@jonwis
jonwis / find_bad_use_of_ref_params.md
Created June 14, 2025 20:44
Copilot-generated CodeQL query

Question

Write a CodeQL query that finds coroutine methods that take parameters by reference, where those parameters are used after any co_await suspension point.

Response

import cpp