This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
NanoSTL is a portable, lightweight subset of C++ STL designed for constrained environments including embedded systems, CUDA devices, and JIT compilers. It's a header-only library with selective implementation requirements.
# Build and run unit tests
cd test
make
./tester
# Alternative CMake build
cd test
cmake .
make
./test_nanostl# Generate consolidated single header file
python scripts/generateSingleHeader.py
# Output: single_include/nanostl.hmkdir build && cd build
cmake ..
make- include/: Main header files - each STL component is in nano*.h files
- src/: Implementation files for components requiring NANOSTL_IMPLEMENTATION
- single_include/: Generated consolidated header file
- compat/: Standard STL compatibility layer
- nanovector.h: STL vector implementation
- nanostring.h: String class with ryu-based float conversion
- nanoalgorithm.h: STL algorithms (sort, find, etc.)
- nanomath.h: Math functions (non-IEEE754 compliant approximations)
- nanomap.h: Associative container
- nanolimits.h: Numeric limits
Each header follows this pattern for single-header generation:
#ifndef NANOSTL_*_H_
#define NANOSTL_*_H_
// ... implementation ...
#endif // NANOSTL_*_H_For functions requiring implementation, use:
#define NANOSTL_IMPLEMENTATION
#include <nanostl.h>- 64-bit architectures only
- Big and little endian
- CUDA device functions
- Windows, Linux, macOS
- C++11 compilers (gcc 4.8+, clang 3.4+)
NANOSTL_BIG_ENDIAN: Set for big endian systemsNANOSTL_NO_IO: Disable I/O operationsNANOSTL_USE_EXCEPTION: Enable exception supportNANOSTL_NO_THREAD: Disable threading featuresNANOSTL_PSTL: Enable parallel STL (requires C++17)NANOSTL_IMPLEMENTATION: Include function implementations
- Not thread-safe by default - applications must handle synchronization
- Use external mutex/locks for concurrent access to containers
- Returns NULL on allocation failure (no bad_alloc exception)
- No automatic exception handling unless NANOSTL_USE_EXCEPTION is defined
- Not IEEE-754 compliant for math functions
- Limited STL compatibility - check feature matrix in README
- No RTTI or exception support by default
- Use CUDA qualifiers for device compatibility
- Follow existing naming conventions (nano* prefixes)
- Implement both header and source file versions where needed
- Maintain compatibility with C++11
- Unit tests require C++11 compiler
- Test both header-only and compiled modes
- Include CUDA platform testing where applicable