joboccara / NamedType

Implementation of strong types in C++
MIT License
766 stars 85 forks source link

Dealing with non-copyable and non-movable types #73

Open gotnone opened 2 years ago

gotnone commented 2 years ago

I have a use case where a microcontroller library has non-copyable type for timers. Unfortunately, the library has not created a move constructor for this type either. Several higher level I/O types contain this timer type and thus inherit this non-copyable nature. I would like to use NamedType with some of these I/O types to distinguish different signals in my program.

I have a minimal example of the on godbolt

Is there any way to use NamedType with these non-copyable types? Is there an equivalent to emplace / inplace construction? Is there any way I can explicitly pass the underlying construction parameters and let NamedType construct the base type from these copyable construction parameters?