From d97049844522b1df7242fd9109720d40d158617e Mon Sep 17 00:00:00 2001 From: Aleksey Gurtovoy Date: Tue, 29 May 2007 06:59:16 +0000 Subject: [PATCH] Add an example that shows use of if_ with dependent entities [SVN r37810] --- doc/src/refmanual/if_.rst | 17 +++++++++++++++++ doc/src/refmanual/if_c.rst | 17 +++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/doc/src/refmanual/if_.rst b/doc/src/refmanual/if_.rst index 85330b8..8ce585c 100644 --- a/doc/src/refmanual/if_.rst +++ b/doc/src/refmanual/if_.rst @@ -76,6 +76,23 @@ Example BOOST_MPL_ASSERT(( is_same )); +.. parsed-literal:: + + // allocates space for an object of class T on heap or "inplace" + // depending on its size + template< typename T > struct lightweight + { + // ... + typedef typename if\_< + less_equal< sizeof\_, sizeof\_ > + , inplace_storage + , heap_storage + >::type impl_t; + + impl_t impl; + }; + + See also -------- diff --git a/doc/src/refmanual/if_c.rst b/doc/src/refmanual/if_c.rst index bdacdd9..3a0c55e 100644 --- a/doc/src/refmanual/if_c.rst +++ b/doc/src/refmanual/if_c.rst @@ -77,6 +77,23 @@ Example BOOST_MPL_ASSERT(( is_same )); +.. parsed-literal:: + + // allocates space for an object of class T on heap or "inplace" + // depending on its size + template< typename T > struct lightweight + { + // ... + typedef typename if_c< + sizeof(T) <= sizeof(T*) + , inplace_storage + , heap_storage + >::type impl_t; + + impl_t impl; + }; + + See also --------