gmock_move_support.h 605 B

1234567891011121314151617181920
  1. // Copyright 2019 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. #ifndef BASE_TEST_GMOCK_MOVE_SUPPORT_H_
  5. #define BASE_TEST_GMOCK_MOVE_SUPPORT_H_
  6. #include <tuple>
  7. #include <utility>
  8. // A similar action as testing::SaveArg, but it does an assignment with
  9. // std::move() instead of always performing a copy.
  10. template <size_t I = 0, typename T>
  11. auto MoveArg(T* out) {
  12. return [out](auto&&... args) {
  13. *out = std::move(std::get<I>(std::tie(args...)));
  14. };
  15. }
  16. #endif // BASE_TEST_GMOCK_MOVE_SUPPORT_H_