Introduce enable_shared_from_this configure check * Introduce enable_shared_from_this to the configure check * Document availability of enable_shared_from_this in style guide
Review: https://reviews.apache.org/r/27356 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b930d5ce Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b930d5ce Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b930d5ce Branch: refs/heads/master Commit: b930d5ce32b60b7c126844a3ef6ae119d36bc8d0 Parents: 9ce7eca Author: Joris Van Remoortere <[email protected]> Authored: Wed Nov 12 11:50:24 2014 -0800 Committer: Dominic Hamon <[email protected]> Committed: Wed Nov 12 11:50:46 2014 -0800 ---------------------------------------------------------------------- docs/mesos-c++-style-guide.md | 3 +++ m4/ax_cxx_compile_stdcxx_11.m4 | 13 +++++++++++++ 2 files changed, 16 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/b930d5ce/docs/mesos-c++-style-guide.md ---------------------------------------------------------------------- diff --git a/docs/mesos-c++-style-guide.md b/docs/mesos-c++-style-guide.md index dfdde85..3cc9ecd 100644 --- a/docs/mesos-c++-style-guide.md +++ b/docs/mesos-c++-style-guide.md @@ -112,3 +112,6 @@ Try<Owned<LocalAuthorizer>> authorizer = LocalAuthorizer::create(); * std::mutex. * std::lock_guard<std::mutex>. * std::unique_lock<std::mutex>. +* Shared from this. + * class T : public std::enable_shared_from_this<T>. + * shared_from_this(). http://git-wip-us.apache.org/repos/asf/mesos/blob/b930d5ce/m4/ax_cxx_compile_stdcxx_11.m4 ---------------------------------------------------------------------- diff --git a/m4/ax_cxx_compile_stdcxx_11.m4 b/m4/ax_cxx_compile_stdcxx_11.m4 index 96f87ea..d166aa1 100644 --- a/m4/ax_cxx_compile_stdcxx_11.m4 +++ b/m4/ax_cxx_compile_stdcxx_11.m4 @@ -92,6 +92,19 @@ m4_define([_AX_CXX_COMPILE_STDCXX_11_testbody], [ // end scope of uniqueLock. } } + + // check for std::enable_shared_from_this. + struct SharedStruct : public std::enable_shared_from_this<SharedStruct> + { + std::shared_ptr<SharedStruct> get() + { + return shared_from_this(); + } + }; + + // construct a new shared_ptr using shared_from_this(). + std::shared_ptr<SharedStruct> object = + std::shared_ptr<SharedStruct>(new SharedStruct())->get(); ]) AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [
