Skip to content

Instantly share code, notes, and snippets.

@sean-parent
sean-parent / test-regular.cpp
Last active December 23, 2015 21:09
Snippet from asl to test regular and movable semantics.
namespace adobe {
// Precondition: x != T()
template <typename T>
void test_regular(const T& x)
{
assert(x != T());
T y = x; // Copy-construct
BOOST_CHECK(x == y);
@sean-parent
sean-parent / test-value-assign
Created September 18, 2013 17:37
Test move assignment by value.
#include <iostream>
using namespace std;
struct annotate {
annotate() { cout << "annotate ctor" << endl; }
annotate(const annotate&) { cout << "annotate copy-ctor" << endl; }
annotate(annotate&&) noexcept { cout << "annotate move-ctor" << endl; }
annotate& operator=(const annotate&) { cout << "annotate assign" << endl; return *this; }
annotate& operator=(annotate&&) noexcept { cout << "annotate move-assign" << endl; return *this; }