mirror of
https://github.com/boostorg/mpl.git
synced 2025-08-03 14:54:30 +02:00
Add an example that shows use of if_ with dependent entities
[SVN r37810]
This commit is contained in:
@@ -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
|
||||
--------
|
||||
|
||||
|
@@ -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
|
||||
--------
|
||||
|
||||
|
Reference in New Issue
Block a user