1 /////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga  2010-2013
4 //
5 // Distributed under the Boost Software License, Version 1.0.
6 //    (See accompanying file LICENSE_1_0.txt or copy at
7 //          http://www.boost.org/LICENSE_1_0.txt)
8 //
9 // See http://www.boost.org/libs/intrusive for documentation.
10 //
11 /////////////////////////////////////////////////////////////////////////////
12 #ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP
13 #define BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP
14 
15 #include <boost/intrusive/detail/config_begin.hpp>
16 #include <boost/intrusive/detail/workaround.hpp>
17 #include <boost/intrusive/intrusive_fwd.hpp>
18 
19 #include <boost/intrusive/detail/parent_from_member.hpp>
20 
21 #if defined(BOOST_HAS_PRAGMA_ONCE)
22 #  pragma once
23 #endif
24 
25 namespace boost {
26 namespace intrusive {
27 
28 //! Given a pointer to a member and its corresponding pointer to data member,
29 //! this function returns the pointer of the parent containing that member.
30 //! Note: this function does not work with pointer to members that rely on
31 //! virtual inheritance.
32 template<class Parent, class Member>
get_parent_from_member(Member * member,const Member Parent::* ptr_to_member)33 BOOST_INTRUSIVE_FORCEINLINE Parent *get_parent_from_member(Member *member, const Member Parent::* ptr_to_member)
34 {  return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member);  }
35 
36 //! Given a const pointer to a member and its corresponding const pointer to data member,
37 //! this function returns the const pointer of the parent containing that member.
38 //! Note: this function does not work with pointer to members that rely on
39 //! virtual inheritance.
40 template<class Parent, class Member>
get_parent_from_member(const Member * member,const Member Parent::* ptr_to_member)41 BOOST_INTRUSIVE_FORCEINLINE const Parent *get_parent_from_member(const Member *member, const Member Parent::* ptr_to_member)
42 {  return ::boost::intrusive::detail::parent_from_member(member, ptr_to_member);  }
43 
44 }  //namespace intrusive {
45 }  //namespace boost {
46 
47 #include <boost/intrusive/detail/config_end.hpp>
48 
49 #endif   //#ifndef BOOST_INTRUSIVE_PARENT_FROM_MEMBER_HPP
50