mirror of
https://github.com/google/googletest.git
synced 2025-12-06 08:46:50 +08:00
Allow for passing non-pointers to DeleteArg and have them emit a deprecation warning instead.
This allows for simpler migration of function args to smart pointers without needing all changes to tests to be atomic. PiperOrigin-RevId: 818635600 Change-Id: I9434685d9640f82b98d0b5261701b78c93d3ec1e
This commit is contained in:
parent
279f847946
commit
2ce9d8f2e8
@ -1796,11 +1796,24 @@ struct SetArrayArgumentAction {
|
|||||||
};
|
};
|
||||||
|
|
||||||
template <size_t k>
|
template <size_t k>
|
||||||
struct DeleteArgAction {
|
class DeleteArgAction {
|
||||||
|
public:
|
||||||
template <typename... Args>
|
template <typename... Args>
|
||||||
void operator()(const Args&... args) const {
|
void operator()(const Args&... args) const {
|
||||||
delete std::get<k>(std::tie(args...));
|
DoDelete(std::get<k>(std::tie(args...)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename T>
|
||||||
|
static void DoDelete(T* ptr) {
|
||||||
|
delete ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
[[deprecated(
|
||||||
|
"DeleteArg<N> used for a non-pointer argument, it was likely migrated "
|
||||||
|
"to a smart pointer type. This action should be removed.")]]
|
||||||
|
static void DoDelete(T&) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Ptr>
|
template <typename Ptr>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user