|
Last change
on this file since 45 was
29,
checked in by landauf, 17 years ago
|
|
updated boost from 1_33_1 to 1_34_1
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | |
|---|
| 2 | // Copyright Aleksey Gurtovoy 2002-2004 |
|---|
| 3 | // |
|---|
| 4 | // Distributed under the Boost Software License, Version 1.0. |
|---|
| 5 | // (See accompanying file LICENSE_1_0.txt or copy at |
|---|
| 6 | // http://www.boost.org/LICENSE_1_0.txt) |
|---|
| 7 | // |
|---|
| 8 | // See http://www.boost.org/libs/mpl for documentation. |
|---|
| 9 | |
|---|
| 10 | // $Source: /cvsroot/boost/boost/libs/mpl/example/inherit_multiply.cpp,v $ |
|---|
| 11 | // $Date: 2004/09/02 15:41:29 $ |
|---|
| 12 | // $Revision: 1.4 $ |
|---|
| 13 | |
|---|
| 14 | #include <boost/mpl/inherit.hpp> |
|---|
| 15 | #include <boost/mpl/inherit_linearly.hpp> |
|---|
| 16 | #include <boost/mpl/list.hpp> |
|---|
| 17 | |
|---|
| 18 | #include <iostream> |
|---|
| 19 | |
|---|
| 20 | namespace mpl = boost::mpl; |
|---|
| 21 | using namespace mpl::placeholders; |
|---|
| 22 | |
|---|
| 23 | template< typename T > |
|---|
| 24 | struct tuple_field |
|---|
| 25 | { |
|---|
| 26 | typedef tuple_field type; // note the typedef |
|---|
| 27 | T field_; |
|---|
| 28 | }; |
|---|
| 29 | |
|---|
| 30 | template< typename T > |
|---|
| 31 | inline |
|---|
| 32 | T& field(tuple_field<T>& t) |
|---|
| 33 | { |
|---|
| 34 | return t.field_; |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | typedef mpl::inherit_linearly< |
|---|
| 38 | mpl::list<int,char const*,bool> |
|---|
| 39 | , mpl::inherit< _1, tuple_field<_2> > |
|---|
| 40 | >::type my_tuple; |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | int main() |
|---|
| 44 | { |
|---|
| 45 | my_tuple t; |
|---|
| 46 | |
|---|
| 47 | field<int>(t) = -1; |
|---|
| 48 | field<char const*>(t) = "text"; |
|---|
| 49 | field<bool>(t) = false; |
|---|
| 50 | |
|---|
| 51 | std::cout |
|---|
| 52 | << field<int>(t) << '\n' |
|---|
| 53 | << field<char const*>(t) << '\n' |
|---|
| 54 | << field<bool>(t) << '\n' |
|---|
| 55 | ; |
|---|
| 56 | |
|---|
| 57 | return 0; |
|---|
| 58 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.