|
@@ -15,6 +15,7 @@
|
|
#include <memory>
|
|
#include <memory>
|
|
#include <cassert>
|
|
#include <cassert>
|
|
|
|
|
|
|
|
+#include "test_macros.h"
|
|
#include "count_new.hpp"
|
|
#include "count_new.hpp"
|
|
|
|
|
|
int A_constructed = 0;
|
|
int A_constructed = 0;
|
|
@@ -34,30 +35,22 @@ struct A
|
|
|
|
|
|
int move_only_constructed = 0;
|
|
int move_only_constructed = 0;
|
|
|
|
|
|
|
|
+#if TEST_STD_VER >= 11
|
|
class move_only
|
|
class move_only
|
|
{
|
|
{
|
|
int data;
|
|
int data;
|
|
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
|
|
- move_only(const move_only&);
|
|
|
|
- move_only& operator=(const move_only&);
|
|
|
|
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
|
|
- move_only(move_only&);
|
|
|
|
- move_only& operator=(move_only&);
|
|
|
|
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
|
|
|
|
|
|
-public:
|
|
|
|
|
|
+ move_only(const move_only&) = delete;
|
|
|
|
+ move_only& operator=(const move_only&)= delete;
|
|
|
|
|
|
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
|
|
|
|
+public:
|
|
move_only(move_only&&) {++move_only_constructed;}
|
|
move_only(move_only&&) {++move_only_constructed;}
|
|
move_only& operator=(move_only&&) {return *this;}
|
|
move_only& operator=(move_only&&) {return *this;}
|
|
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
|
|
- operator std::__rv<move_only> () {return std::__rv<move_only>(*this);}
|
|
|
|
- move_only(std::__rv<move_only>) {++move_only_constructed;}
|
|
|
|
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
|
|
|
|
|
|
|
|
move_only() {++move_only_constructed;}
|
|
move_only() {++move_only_constructed;}
|
|
~move_only() {--move_only_constructed;}
|
|
~move_only() {--move_only_constructed;}
|
|
};
|
|
};
|
|
|
|
+#endif // TEST_STD_VER >= 11
|
|
|
|
|
|
int main()
|
|
int main()
|
|
{
|
|
{
|
|
@@ -108,6 +101,7 @@ int main()
|
|
assert(globalMemCounter.checkOutstandingNewEq(0));
|
|
assert(globalMemCounter.checkOutstandingNewEq(0));
|
|
assert(A_constructed == 0);
|
|
assert(A_constructed == 0);
|
|
}
|
|
}
|
|
|
|
+#if TEST_STD_VER >= 11
|
|
{
|
|
{
|
|
std::allocator<move_only> a;
|
|
std::allocator<move_only> a;
|
|
assert(globalMemCounter.checkOutstandingNewEq(0));
|
|
assert(globalMemCounter.checkOutstandingNewEq(0));
|
|
@@ -139,4 +133,5 @@ int main()
|
|
assert(globalMemCounter.checkOutstandingNewEq(0));
|
|
assert(globalMemCounter.checkOutstandingNewEq(0));
|
|
assert(move_only_constructed == 0);
|
|
assert(move_only_constructed == 0);
|
|
}
|
|
}
|
|
|
|
+#endif
|
|
}
|
|
}
|