Skip to content

This is a `std::any`-like type for C++17 that works with move-only types

License

Notifications You must be signed in to change notification settings

mika-fischer/mcpp-unique-any

Repository files navigation

unique-any

Ubuntu Windows macOS

std::any-like type for C++17 that works with move-only and immovable types.

Other than working with non-copyable types, and being non-copyable, this works the same as std::any.

Usage

auto move_only = std::make_unique<some_class>();                       // Works with move-only types
auto any1 = mcpp::unique_any(std::move(move_only));
auto any2 = mcpp::unique_any(std::inplace_type<std::atomic<int>>, 42); // Works with immovable types
auto any3 = std::move(any1);                                           // Can be moved
// auto any4 = any2;                                                   // Cannot be copied

Future work

  • Support no-rtti mode
  • Support no-exception mode
  • Support C++14?

License

This software is licensed under the Boost Software License - Version 1.0.

About

This is a `std::any`-like type for C++17 that works with move-only types

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published