44 lines · c
1//===----------------------------------------------------------------------===//2//3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.4// See https://llvm.org/LICENSE.txt for license information.5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception6//7//===----------------------------------------------------------------------===//8 9#ifndef TEST_SUPPORT_DOUBLE_MOVE_TRACKER_H10#define TEST_SUPPORT_DOUBLE_MOVE_TRACKER_H11 12#include <cassert>13 14#include "test_macros.h"15 16namespace support {17 18struct double_move_tracker {19 TEST_CONSTEXPR double_move_tracker() : moved_from_(false) {}20 21 double_move_tracker(double_move_tracker const&) = default;22 23 TEST_CONSTEXPR_CXX14 double_move_tracker(double_move_tracker&& other) : moved_from_(false) {24 assert(!other.moved_from_);25 other.moved_from_ = true;26 }27 28 double_move_tracker& operator=(double_move_tracker const&) = default;29 30 TEST_CONSTEXPR_CXX14 double_move_tracker& operator=(double_move_tracker&& other) {31 assert(!other.moved_from_);32 other.moved_from_ = true;33 moved_from_ = false;34 return *this;35 }36 37private:38 bool moved_from_;39};40 41} // namespace support42 43#endif // TEST_SUPPORT_DOUBLE_MOVE_TRACKER_H44