Skip to content

A minimal C++23 project template using Bazel build system to explore and experiment with modern C++ features.

License

Notifications You must be signed in to change notification settings

florianfueller/cpp-playground

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++23 Playground

A minimal C++23 project template using Bazel build system to explore and experiment with modern C++ features.

Features

  • Zero Installation Compiler: Bazel automatically downloads LLVM 20.1.3 toolchain into its cache - no need to install a compiler on your system!
  • Modern C++ Standards: Configured for C++23
  • Hermetic Builds: Reproducible builds across different machines using the same cached toolchain
  • Bazel Build System: Fast, incremental builds using Bzlmod
  • Example Code: Demonstrates C++23 concepts with numeric type constraints

Prerequisites

  • Bazel (latest version recommended)
  • That's it! No compiler installation needed - Bazel handles everything

Quick Start

# Build the project (first run will download LLVM toolchain into Bazel cache)
bazel build //:main

# Run the executable
bazel run //:main

Note: On the first build, Bazel will download the LLVM 20.1.3 toolchain (~200MB) into its cache. This is a one-time operation. Subsequent builds will use the cached toolchain.

Project Structure

cpp23-playground/
├── BUILD.bazel          # Bazel build configuration
├── MODULE.bazel         # Bazel module definition
├── MODULE.bazel.lock    # Dependency lock file
├── .bazelrc             # Bazel configuration options
├── main.cpp             # Example C++23 code
└── README.md            # This file

What's Inside

The example code demonstrates:

  • C++23 Concepts: Custom Numeric concept using type constraints
  • Abbreviated Function Templates: Using auto parameters with concepts
  • Modern Type Traits: std::integral and std::floating_point

Adding More Examples

To add new C++23 examples:

  1. Create a new .cpp file
  2. Add it to BUILD.bazel:
    cc_binary(
        name = "your_example",
        srcs = ["your_example.cpp"],
    )
  3. Build and run: bazel run //:your_example

License

MIT License - feel free to use this as a template for your own C++23 projects.

Contributing

This is a personal playground, but suggestions for interesting C++23 examples are welcome!

About

A minimal C++23 project template using Bazel build system to explore and experiment with modern C++ features.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published