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 14 CopyableType::CopyableType() : copied_(false), ptr_(this) { 15 num_instances_++; 16 } 17 18 CopyableType::CopyableType(const CopyableType& other) 19 : copied_(true), ptr_(other.ptr()) { 20 num_instances_++; 21 } 22 23 CopyableType& CopyableType::operator=(const CopyableType& other) { 24 copied_ = true; 25 ptr_ = other.ptr(); 26 return *this; 27 } 28 29 CopyableType::~CopyableType() { 30 num_instances_--; 31 } 32 33 MoveOnlyType::MoveOnlyType() : moved_(false), ptr_(this) { 34 num_instances_++; 35 } 36 37 MoveOnlyType::MoveOnlyType(MoveOnlyType&& other) 38 : moved_(true), ptr_(other.ptr()) { 39 num_instances_++; 40 } 41 42 MoveOnlyType& MoveOnlyType::operator=(MoveOnlyType&& other) { 43 moved_ = true; 44 ptr_ = other.ptr(); 45 return *this; 46 } 47 48 MoveOnlyType::~MoveOnlyType() { 49 num_instances_--; 50 } 51 52 } // namespace mojo 53