From 82b9af71dd5aa3ad6fee808e91e9b1024ebaeafb Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Tue, 19 May 2020 21:19:58 +0300 Subject: Improve std::optional to better deal with lack of copy/move constructors --- tests/optional/buildfile | 6 ++++++ tests/optional/driver.cxx | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 tests/optional/buildfile create mode 100644 tests/optional/driver.cxx (limited to 'tests/optional') diff --git a/tests/optional/buildfile b/tests/optional/buildfile new file mode 100644 index 0000000..68188d7 --- /dev/null +++ b/tests/optional/buildfile @@ -0,0 +1,6 @@ +# file : tests/optional/buildfile +# license : MIT; see accompanying LICENSE file + +import libs = libbutl%lib{butl} + +exe{driver}: {hxx cxx}{*} $libs diff --git a/tests/optional/driver.cxx b/tests/optional/driver.cxx new file mode 100644 index 0000000..5d72f08 --- /dev/null +++ b/tests/optional/driver.cxx @@ -0,0 +1,43 @@ +// file : tests/optional/driver.cxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#include + +#ifndef __cpp_lib_modules_ts +#include +#include // move() +#endif + +// Other includes. + +#ifdef __cpp_modules_ts +#ifdef __cpp_lib_modules_ts +import std.core; +#endif +import butl.optional; +#else +#include +#endif + +using namespace std; + +struct move_only +{ + move_only () = default; + + move_only (move_only&&) = default; + move_only& operator= (move_only&&) = default; + + move_only (const move_only&) = delete; + move_only& operator= (const move_only&) = delete; +}; + +int +main () +{ + using butl::optional; + + optional r; + vector> rs; + rs.emplace_back (move (r)); +} -- cgit v1.1