For example:
std::weak_ptr<int> wp1(std::make_shared<int>());
std::weak_ptr<int> wp2;
assert(PointsToValidOrExpiredObject(wp1));
assert(!PointsToValidOrExpiredObject(wp2));
Is such a function possible?
Use case: A class's constructor takes std::weak_ptr<Foo>
as a dependency. Passing an expired object is ok (might happen in certain workflows), but passing null means the programmer forget something. I'd like to test for this as part of the constructor's parameter validation.