# foonathan/type_safe

Zero overhead utilities for preventing bugs at compile time

Repository: https://github.com/foonathan/type_safe
Canonical: https://ross.abutalabs.com/products/type_safe
Homepage: https://type_safe.foonathan.net
Language: C++
License: MIT
License Family: permissive
Topics: c-plus-plus, type-safety
Last push: 2025-10-13T19:19:38+00:00

## Health v2 (maintenance only)
Score: 44/100 (v2, computed 2026-09-03T02:20:16.233290+00:00)
- activity 46, release rhythm 8, longevity 100
- inputs: {"age_days": 3616, "days_push": 324, "days_rel": null, "gap_med": null, "n_releases_24m": 0}
- flags: none
- formula: round(0.45*activity + 0.35*rhythm + 0.20*longevity); archived -> min(score, 10)

## Adoption (not part of the score)
Stars 1649, forks 128 (observed 2026-08-28T04:05:16.774907+00:00)

## What it is
A C++ library providing zero-overhead abstractions that leverage the type system to prevent bugs at compile time. It offers improved wrappers for built-in types, vocabulary types like non-null references, and enhanced optional/variant implementations.

## Use cases
- prevent integer overflow and lossy conversion bugs at compile time
- enforce non-null pointers in C++ APIs
- replace raw bool parameters with expressive flag types
- get a space-efficient optional type with no overhead
- make C++ APIs safer using strong typedefs
- constrain values with validated types

## When to choose
- you write modern C++ and want compile-time prevention of common bugs like uninitialized values or lossy conversions
- you need zero runtime overhead in release builds while keeping debug-mode assertions
- you want safer alternatives to std::optional, std::variant, and raw pointers

## When to avoid
- you work in a language other than C++
- you need runtime type safety or dynamic validation rather than compile-time guarantees
- your codebase cannot adopt C++11 or newer standards

## Facets
- artifact type: library
- maturity: active
- function: type-system, error-handling
- domain: programming-languages, developer-tools
- platform: cpp, cross-platform
- tags: type-safety, zero-overhead, vocabulary-types, strong-typedefs, header-only, optional, variant, algorithms

## Member repositories
- foonathan/type_safe (main) score 44

## Provenance
- Observed fields: from GitHub, fetched 2026-08-28T04:05:16.774907+00:00.
- Health v2: computed from the inputs above; adoption is never an input.
- Inferred fields (summary, facets, guidance): AI-extracted, prompt v1, taxonomy v1, on 2026-08-30T03:45:08.966544+00:00, confidence not recorded.
  - readme: https://github.com/foonathan/type_safe (fetched 2026-08-28T04:05:16.774907+00:00, sha c1d63658e8d5)
- Data as of 2026-08-30T08:39:29.467469+00:00.
