1<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 2<html> 3<head> 4<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 5<title>Composing Concepts</title> 6<link rel="stylesheet" href="../../../doc/src/boostbook.css" type="text/css"> 7<meta name="generator" content="DocBook XSL Stylesheets V1.79.1"> 8<link rel="home" href="../index.html" title="The Boost C++ Libraries BoostBook Documentation Subset"> 9<link rel="up" href="../boost_typeerasure.html" title="Chapter 40. Boost.TypeErasure"> 10<link rel="prev" href="basic.html" title="Basic Usage"> 11<link rel="next" href="multi.html" title="Functions with Multiple Arguments"> 12</head> 13<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> 14<table cellpadding="2" width="100%"><tr> 15<td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../boost.png"></td> 16<td align="center"><a href="../../../index.html">Home</a></td> 17<td align="center"><a href="../../../libs/libraries.htm">Libraries</a></td> 18<td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> 19<td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> 20<td align="center"><a href="../../../more/index.htm">More</a></td> 21</tr></table> 22<hr> 23<div class="spirit-nav"> 24<a accesskey="p" href="basic.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_typeerasure.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="multi.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 25</div> 26<div class="section"> 27<div class="titlepage"><div><div><h2 class="title" style="clear: both"> 28<a name="boost_typeerasure.composing_concepts"></a><a class="link" href="composing_concepts.html" title="Composing Concepts">Composing Concepts</a> 29</h2></div></div></div> 30<p> 31 (For the source of the examples in this section see <a href="../../../libs/type_erasure/example/compose.cpp" target="_top">compose.cpp</a>) 32 </p> 33<p> 34 Multiple concepts can be composed using an MPL sequence. 35 </p> 36<p> 37</p> 38<pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span> <span class="special">=</span> <span class="identifier">_self</span><span class="special">></span> 39<span class="keyword">struct</span> <span class="identifier">arithmetic</span> <span class="special">:</span> 40 <span class="identifier">mpl</span><span class="special">::</span><span class="identifier">vector</span><span class="special"><</span> 41 <span class="identifier">copy_constructible</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> 42 <span class="identifier">addable</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> 43 <span class="identifier">subtractable</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> 44 <span class="identifier">multipliable</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> 45 <span class="identifier">dividable</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> 46 <span class="identifier">equality_comparable</span><span class="special"><</span><span class="identifier">T</span><span class="special">>,</span> 47 <span class="identifier">less_than_comparable</span><span class="special"><</span><span class="identifier">T</span><span class="special">></span> 48 <span class="special">></span> 49<span class="special">{};</span> 50</pre> 51<p> 52 </p> 53<p> 54 Now, <code class="computeroutput"><span class="identifier">arithmetic</span></code> is a concept 55 that can be used just like any of the base concepts. 56 </p> 57</div> 58<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> 59<td align="left"></td> 60<td align="right"><div class="copyright-footer">Copyright © 2011-2013 Steven Watanabe<p> 61 Distributed under the Boost Software License, Version 1.0. (See accompanying 62 file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>) 63 </p> 64</div></td> 65</tr></table> 66<hr> 67<div class="spirit-nav"> 68<a accesskey="p" href="basic.html"><img src="../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../boost_typeerasure.html"><img src="../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="multi.html"><img src="../../../doc/src/images/next.png" alt="Next"></a> 69</div> 70</body> 71</html> 72