I noticed a lot of the "Primary section" column is wrong in the C++17 feature table. Several sections got renumbered recently, so the features that were in there a few months ago have the wrong number now. For example, some of the shared_ptr utils are listed as 20.8, but weak_type is 20.10. In the latest draft they're all 20.11!
On 22 July 2016 at 20:06, Nelson, Clark <[email protected]> wrote: > What I have done instead is add an indication for every proposed macro for > which we don't yet have an example -- which is to say, for which we don't > yet have a rationale. I'd really like to get more examples -- but I don't > plan to do all the work of inventing them myself. Example for P0163R0 __cpp_lib_shared_ptr_weak_type: template<class ObjectType> void register_observers(ObjectType& obj) { auto sptr = obj.shared_from_this(); #if __cpp_lib_shared_ptr_weak_type decltype(sptr)::weak_type wptr(sptr); #else // Fails if sptr is not std::shared_ptr // (e.g. std::experimental::shared_ptr or boost::shared_ptr) auto wptr = weak_ptr<decltype(sptr)::element_type>(sptr); #endif sptr.reset(); // drop the strong reference as soon as possible register_observer_1(wptr); register_observer_2(wptr); } And similar example for P0033R1 __cpp_lib_enable_shared_from_this: template<class ObjectType> void register_observers(ObjectType& obj) { #if __cpp_lib_enable_shared_from_this auto wptr = obj.weak_from_this(); #else auto sptr = obj.shared_from_this(); // Fails if sptr is not std::shared_ptr // (e.g. std::experimental::shared_ptr or boost::shared_ptr) auto wptr = weak_ptr<decltype(sptr)::element_type>(sptr); sptr.reset(); // drop the strong reference as soon as possible #endif register_observer_1(wptr); register_observer_2(wptr); } I tried to come up with one for P0074R0, but I don't think this is very good because if you're going to write the fallback anyway then the macro doesn't help much: #if __cpp_lib_transparent_operators >= 201510 using generic_owner_less = std::owner_less<>; #else struct generic_owner_less { template<typename T, typename U> bool operator()(const std::shared_ptr<T>& p1, const std::shared_ptr<U>& p2) const { return p1.owner_before(p2); } }; #endif _______________________________________________ Features mailing list [email protected] http://www.open-std.org/mailman/listinfo/features
