1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #include <stddef.h> 6 7 #include "mojo/public/cpp/bindings/tests/container_test_util.h" 8 9 namespace mojo { 10 11 size_t CopyableType::num_instances_ = 0; 12 size_t MoveOnlyType::num_instances_ = 0; 13 CopyableType()14CopyableType::CopyableType() : copied_(false), ptr_(this) { 15 num_instances_++; 16 } 17 CopyableType(const CopyableType & other)18CopyableType::CopyableType(const CopyableType& other) 19 : copied_(true), ptr_(other.ptr()) { 20 num_instances_++; 21 } 22 operator =(const CopyableType & other)23CopyableType& CopyableType::operator=(const CopyableType& other) { 24 copied_ = true; 25 ptr_ = other.ptr(); 26 return *this; 27 } 28 ~CopyableType()29CopyableType::~CopyableType() { 30 num_instances_--; 31 } 32 MoveOnlyType()33MoveOnlyType::MoveOnlyType() : moved_(false), ptr_(this) { 34 num_instances_++; 35 } 36 MoveOnlyType(MoveOnlyType && other)37MoveOnlyType::MoveOnlyType(MoveOnlyType&& other) 38 : moved_(true), ptr_(other.ptr()) { 39 num_instances_++; 40 } 41 operator =(MoveOnlyType && other)42MoveOnlyType& MoveOnlyType::operator=(MoveOnlyType&& other) { 43 moved_ = true; 44 ptr_ = other.ptr(); 45 return *this; 46 } 47 ~MoveOnlyType()48MoveOnlyType::~MoveOnlyType() { 49 num_instances_--; 50 } 51 52 } // namespace mojo 53