Back to Arangodb

inherit_linearly

3rdParty/boost/1.78.0/libs/mpl/doc/refmanual/inherit-linearly.html

3.12.9.13.3 KB
Original Source

| Prev Next | Back Along | Up Home | Full TOC | Front Page / Metafunctions / Miscellaneous / inherit_linearly |

inherit_linearly

Synopsis

template<
      typename Types
    , typename Node
    , typename Root =[empty\_base](./empty-base.html)>
struct[inherit\_linearly](./inherit-linearly.html):[fold](./fold.html)<Types,Root,Node>
{
};

Description

A convenience wrapper for fold to use in the context of sequence-driven class composition. Returns the result the successive application of binary Node to the result of the previous Node invocation (Root if it's the first call) and every type in the Forward Sequence Types in order.

#include <[boost/mpl/inherit\_linearly.hpp](../../../../boost/mpl/inherit_linearly.hpp)>

Model of

Metafunction

Parameters

ParameterRequirementDescription
TypesForward SequenceTypes to inherit from.
NodeBinary Lambda ExpressionA derivation metafunction.
RootA class typeA type to be placed at the root of the class hierarchy.

Expression semantics

For any Forward Sequence types, binary Lambda Expression node, and arbitrary class type root:

typedef[inherit\_linearly](./inherit-linearly.html)<types,node,root>::type r;

| Return type: |

A class type.

| | Semantics: |

Equivalent to

typedef[fold](./fold.html)<types,root,node>::type r;

|

Complexity

Linear. Exactly size<types>::value applications of node.

Example

template< typename T > struct tuple_field
{
    T field;
};

template< typename T >
inline
T& field(tuple_field<T>& t)
{
    return t.field;
}

typedef[inherit\_linearly](./inherit-linearly.html)<[vector](./vector.html)<int,char const*,bool>
    ,[inherit](./inherit.html)<[\_1](./placeholders.html), tuple_field<[\_2](./placeholders.html)> >
    >::type tuple;

int main()
{
    tuple t;

    field<int>(t) = -1;
    field<char const*>(t) = "text";
    field<bool>(t) = false;

    std::cout
        << field<int>(t) << 'n'
        << field<char const*>(t) << 'n'
        << field<bool>(t) << 'n'
        ;
}

See also

Metafunctions, Algorithms, inherit, empty_base, fold, reverse_fold

| Prev Next | Back Along | Up Home | Full TOC |

Copyright © 2001-2009 Aleksey Gurtovoy and David Abrahams Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |