cppany
A wrapper for C++'s std::any
Summary
| Latest Version | Unknown |
|---|---|
| License | MIT |
| CI Status | Failing |
| Downloads | 0 |
| Last Indexed | 2026-07-21 05:25 |
Tags
Installation
nimble install cppany
choosenim install cppany
git clone https://github.com/sls1005/cppany
OS Compatibility
| Platform | Linux | macOS | Windows | FreeBSD | OpenBSD | NetBSD | Android | iOS | WASM | Embedded |
|---|---|---|---|---|---|---|---|---|---|---|
| cppany | ✓ | ✓ | ✓ | - | - | - | - | - | - | - |
Source
| Repository | https://github.com/sls1005/cppany |
|---|---|
| Homepage | https://github.com/sls1005/cppany |
| Registry Source | nimble_official |
README
CPP Any
A Nim wrapper for C++'s std::any.
Example
import cppany
var a: Any = 1
echo castAny[int](a) # 1
a = 2.5
echo castAny[float](a) # 2.5
a = 'A'
echo castAny[char](a) # 'A'
Note
-
Do not get confused with the
Anytype from this module and that fromstd/typeinfo. (In this manual,Anyrefers to the former.) Those two types should not be used in the same module, even if it's possible. -
One can only cast
Anyto the type of which it stores (viacastAny), otherwise a BadAnyCast is raised. -
Do not use
Anyto store GC'ed types (seq,string, ...), unless you fully understand the memory-managing strategy you choose. -
Due to some technical limitations, One cannot have a
seqofAny, but can have anarrayof them. -
As
std::anywas defined in C++17 (Nim currently uses C++14), this module requires you to pass a flag to the backend C++ compiler (via--passC), telling it to use the new standard. However, if you're with GCC or Clang, it is automatically done by this module, so you don't have to worry about that. -
In a project that uses this module, the
{.register.}pragma cannot be used, as it's incompatible with C++17.