Problem
The library is missing fundamental utility types and iterator infrastructure that C++ STL developers rely on daily. Without pair, tuple, and iterator utilities, many common patterns cannot be expressed cleanly in PythonSTL style.
Missing Utility Types (<utility> / <optional> / <variant>)
| Class |
C++ Equivalent |
Description |
pair |
std::pair<T1,T2> |
Two-element typed pair with .first and .second |
tuple |
std::tuple<T...> |
N-element typed tuple with get<N>(), make_tuple(), tie() |
optional |
std::optional<T> |
A value that may or may not exist |
variant |
std::variant<T...> |
Type-safe tagged union |
bitset |
std::bitset<N> |
Fixed-size bit array with AND, OR, XOR ops |
string_stl |
std::string wrapper |
STL-style string: find, substr, erase, replace, compare |
Missing Iterator Utilities
| Function/Class |
C++ Equivalent |
Description |
advance(it, n) |
std::advance |
Moves iterator forward by n steps |
distance(a, b) |
std::distance |
Number of steps between two iterators |
next(it, n) |
std::next |
Returns iterator advanced by n |
prev(it, n) |
std::prev |
Returns iterator moved back by n |
reverse_iterator |
std::reverse_iterator |
Wraps any iterator to iterate in reverse |
Iterator base classes |
— |
Forward, Bidirectional, RandomAccess base classes |
Expected API
from pythonstl.utility import pair, optional, bitset
from pythonstl.iterator import advance, distance, reverse_iterator
# pair
p = pair(10, "hello")
print(p.first, p.second) # 10 hello
# optional
val = optional(42)
print(val.has_value()) # True
print(val.value()) # 42
empty = optional()
print(empty.has_value()) # False
# bitset
b = bitset(8) # 8-bit bitset
b.set(3)
b.set(5)
print(b.to_string()) # 00101000
print(b.count()) # 2
# iterator
arr = [1, 2, 3, 4, 5]
it = iter(arr)
advance(it, 2)
print(distance(iter(arr), it)) # 2
Checklist
Utility Types
Iterator Utilities
General
Notes
pair and tuple are the highest priority as they are returned by many STL functions (e.g., equal_range returns a pair).
bitset has no direct Python built-in equivalent, making it a strong differentiator for this library.
- Iterator utilities are needed to properly support future range-based algorithms.
Problem
The library is missing fundamental utility types and iterator infrastructure that C++ STL developers rely on daily. Without
pair,tuple, and iterator utilities, many common patterns cannot be expressed cleanly in PythonSTL style.Missing Utility Types (
<utility>/<optional>/<variant>)pairstd::pair<T1,T2>.firstand.secondtuplestd::tuple<T...>get<N>(),make_tuple(),tie()optionalstd::optional<T>variantstd::variant<T...>bitsetstd::bitset<N>string_stlstd::stringwrapperfind,substr,erase,replace,compareMissing Iterator Utilities
advance(it, n)std::advancedistance(a, b)std::distancenext(it, n)std::nextprev(it, n)std::prevreverse_iteratorstd::reverse_iteratorIteratorbase classesExpected API
Checklist
Utility Types
pairtupleoptionalvariantbitsetstring_stlwrapperIterator Utilities
advance,distance,next,prevreverse_iteratorwrapperGeneral
Notes
pairandtupleare the highest priority as they are returned by many STL functions (e.g.,equal_rangereturns a pair).bitsethas no direct Python built-in equivalent, making it a strong differentiator for this library.