variant
A header-only C++11/C++14 alternative to boost::variant. It provides a type-safe way to hold one of several types, such as a result or an error.
Pick a small issue you can reproduce, then fix it with your AI coding agent.
Share on XLicense: BSD-3-Clause
Overview
Mapbox Variant is a header-only alternative to boost::variant for C++11 and C++14. It gives a type-safe way to hold one of several types, for example an API response that is either a result or an error. It offers pattern matching with lambdas, visitors, and a recursive wrapper for tree-like types such as JSON. It has no dependencies.
Key features
- Type-safe variant for sum types and discriminated unions
- match() member takes lambdas and checks all types are handled
- apply_visitor and get() for visiting or unwrapping values
- recursive_wrapper supports recursive types such as JSON trees
Best for
C++11 or C++14 projects that want variant types without depending on Boost. It aims for a drop-in API with boost::variant but implements only the features actually needed.
- Upstream
- mapbox/variant
- Fork on GitHub
- Guo-astro/variant
- Upstream stars
- 384
- Category
- Developer tools and infrastructure
- Language
- C++
- License
- BSD-3-Clause
- Forked
- 2020-11-01
- Sync status
- In syncLast synced 2026-10-19
More in Developer tools and infrastructure
An open-source TypeScript engine for calculating Zi Wei Dou Shu charts and consulting traditional references. It helps developers build charting and interpretation tools.
Forked 2026-10-18Last synced 2026-10-19License: MITDeveloper tools and infrastructureGitHub
ImHex is a hex editor for inspecting and editing binary files. Reverse engineers, programmers, and forensic users can search and patch bytes or describe file structures with its pattern language.
Forked 2026-10-17Last synced 2026-10-19License: GPL-2.0Developer tools and infrastructureGitHub
Numa is a portable DNS resolver for local development and privacy. It blocks ads, gives local services names like frontend.numa, and runs without depending on a cloud account.
Forked 2026-10-17Last synced 2026-10-19License: MITDeveloper tools and infrastructureGitHub
Handwired turns ordinary JavaScript logic into differentiable neural-network-style calculations, so programs can run as matrix operations in JavaScript or WebGPU. It is for experimenting with GPU execution and optimization of code written in a traditional style.
Forked 2026-10-16Last synced 2026-10-19License: MITDeveloper tools and infrastructureGitHub