Add an example that shows use of if_ with dependent entities

[SVN r37810]
This commit is contained in:
Aleksey Gurtovoy
2007-05-29 06:59:16 +00:00
parent b4048c1b75
commit d970498445
2 changed files with 34 additions and 0 deletions

View File

@@ -76,6 +76,23 @@ Example
BOOST_MPL_ASSERT(( is_same<t2, long> ));
.. 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\_<T>, sizeof\_<T*> >
, inplace_storage<T>
, heap_storage<T>
>::type impl_t;
impl_t impl;
};
See also
--------

View File

@@ -77,6 +77,23 @@ Example
BOOST_MPL_ASSERT(( is_same<t2, long> ));
.. 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<T>
, heap_storage<T>
>::type impl_t;
impl_t impl;
};
See also
--------