Unsigned integer types for `var`


#1

Is there any chance we can get unsigned integer support for var?

Use case: I’m experimenting with a ValueTree-backed version of the AudioPluginHost and AudioProcessorGraph::NodeID explicitly requires unit32 to construct. While casting solves this, it’s not the prettiest of code


#2

Nope. A couple of reasons why not:

  • one of the purposes of var is to be compatible with JSON types, and they don’t have an unsigned int
  • It all gets saved as XML, which only has strings, so when reading it back there’d be no way to know whether “1” was signed or unsigned
  • It’s really not hard to create wrappers to present vars as your own custom types - that’s what CachedValue is for. Or just create a simple free function that gets an unsigned value from a var and hides the cast - that ends up being as concise as the code would be if it did have an unsigned type built in.

#3

Thanks for the explanation :slight_smile: I’d already gone down the free function route to clean-up