5 <!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]-->
6 <meta name="viewport" content="width=device-width, initial-scale=1.0">
7 <meta name="generator" content="Asciidoctor 1.5.8">
8 <meta name="author" content="Peter Dimov">
9 <title>Boost.Mp11: A C++11 metaprogramming library</title>
10 <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700">
12 /* Asciidoctor default stylesheet | MIT License | http://asciidoctor.org */
13 /* Uncomment @import statement below to use as custom stylesheet */
14 /*@import "https://fonts.googleapis.com/css?family=Open+Sans:300,300italic,400,400italic,600,600italic%7CNoto+Serif:400,400italic,700,700italic%7CDroid+Sans+Mono:400,700";*/
15 article,aside,details,figcaption,figure,footer,header,hgroup,main,nav,section,summary{display:block}
16 audio,canvas,video{display:inline-block}
17 audio:not([controls]){display:none;height:0}
18 script{display:none!important}
19 html{font-family:sans-serif;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
20 a{background:transparent}
21 a:focus{outline:thin dotted}
22 a:active,a:hover{outline:0}
23 h1{font-size:2em;margin:.67em 0}
24 abbr[title]{border-bottom:1px dotted}
25 b,strong{font-weight:bold}
26 dfn{font-style:italic}
27 hr{-moz-box-sizing:content-box;box-sizing:content-box;height:0}
28 mark{background:#ff0;color:#000}
29 code,kbd,pre,samp{font-family:monospace;font-size:1em}
30 pre{white-space:pre-wrap}
31 q{quotes:"\201C" "\201D" "\2018" "\2019"}
33 sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}
37 svg:not(:root){overflow:hidden}
39 fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}
40 legend{border:0;padding:0}
41 button,input,select,textarea{font-family:inherit;font-size:100%;margin:0}
42 button,input{line-height:normal}
43 button,select{text-transform:none}
44 button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}
45 button[disabled],html input[disabled]{cursor:default}
46 input[type="checkbox"],input[type="radio"]{box-sizing:border-box;padding:0}
47 button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}
48 textarea{overflow:auto;vertical-align:top}
49 table{border-collapse:collapse;border-spacing:0}
50 *,*::before,*::after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}
51 html,body{font-size:100%}
52 body{background:#fff;color:rgba(0,0,0,.8);padding:0;margin:0;font-family:"Noto Serif","DejaVu Serif",serif;font-weight:400;font-style:normal;line-height:1;position:relative;cursor:auto;tab-size:4;-moz-osx-font-smoothing:grayscale;-webkit-font-smoothing:antialiased}
53 a:hover{cursor:pointer}
54 img,object,embed{max-width:100%;height:auto}
55 object,embed{height:100%}
56 img{-ms-interpolation-mode:bicubic}
57 .left{float:left!important}
58 .right{float:right!important}
59 .text-left{text-align:left!important}
60 .text-right{text-align:right!important}
61 .text-center{text-align:center!important}
62 .text-justify{text-align:justify!important}
64 img,object,svg{display:inline-block;vertical-align:middle}
65 textarea{height:auto;min-height:50px}
67 .center{margin-left:auto;margin-right:auto}
69 .subheader,.admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{line-height:1.45;color:#7a2518;font-weight:400;margin-top:0;margin-bottom:.25em}
70 div,dl,dt,dd,ul,ol,li,h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6,pre,form,p,blockquote,th,td{margin:0;padding:0;direction:ltr}
71 a{color:#2156a5;text-decoration:underline;line-height:inherit}
72 a:hover,a:focus{color:#1d4b8f}
74 p{font-family:inherit;font-weight:400;font-size:1em;line-height:1.6;margin-bottom:1.25em;text-rendering:optimizeLegibility}
75 p aside{font-size:.875em;line-height:1.35;font-style:italic}
76 h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{font-family:"Open Sans","DejaVu Sans",sans-serif;font-weight:300;font-style:normal;color:#ba3925;text-rendering:optimizeLegibility;margin-top:1em;margin-bottom:.5em;line-height:1.0125em}
77 h1 small,h2 small,h3 small,#toctitle small,.sidebarblock>.content>.title small,h4 small,h5 small,h6 small{font-size:60%;color:#e99b8f;line-height:0}
79 h2{font-size:1.6875em}
80 h3,#toctitle,.sidebarblock>.content>.title{font-size:1.375em}
81 h4,h5{font-size:1.125em}
83 hr{border:solid #dddddf;border-width:1px 0 0;clear:both;margin:1.25em 0 1.1875em;height:0}
84 em,i{font-style:italic;line-height:inherit}
85 strong,b{font-weight:bold;line-height:inherit}
86 small{font-size:60%;line-height:inherit}
87 code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
88 ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
89 ul,ol{margin-left:1.5em}
90 ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
91 ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
92 ul.square{list-style-type:square}
93 ul.circle{list-style-type:circle}
94 ul.disc{list-style-type:disc}
95 ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
96 dl dt{margin-bottom:.3125em;font-weight:bold}
97 dl dd{margin-bottom:1.25em}
98 abbr,acronym{text-transform:uppercase;font-size:90%;color:rgba(0,0,0,.8);border-bottom:1px dotted #ddd;cursor:help}
99 abbr{text-transform:none}
100 blockquote{margin:0 0 1.25em;padding:.5625em 1.25em 0 1.1875em;border-left:1px solid #ddd}
101 blockquote cite{display:block;font-size:.9375em;color:rgba(0,0,0,.6)}
102 blockquote cite::before{content:"\2014 \0020"}
103 blockquote cite a,blockquote cite a:visited{color:rgba(0,0,0,.6)}
104 blockquote,blockquote p{line-height:1.6;color:rgba(0,0,0,.85)}
105 @media screen and (min-width:768px){h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2}
107 h2{font-size:2.3125em}
108 h3,#toctitle,.sidebarblock>.content>.title{font-size:1.6875em}
109 h4{font-size:1.4375em}}
110 table{background:#fff;margin-bottom:1.25em;border:solid 1px #dedede}
111 table thead,table tfoot{background:#f7f8f7}
112 table thead tr th,table thead tr td,table tfoot tr th,table tfoot tr td{padding:.5em .625em .625em;font-size:inherit;color:rgba(0,0,0,.8);text-align:left}
113 table tr th,table tr td{padding:.5625em .625em;font-size:inherit;color:rgba(0,0,0,.8)}
114 table tr.even,table tr.alt,table tr:nth-of-type(even){background:#f8f8f7}
115 table thead tr th,table tfoot tr th,table tbody tr td,table tr td,table tfoot tr td{display:table-cell;line-height:1.6}
116 h1,h2,h3,#toctitle,.sidebarblock>.content>.title,h4,h5,h6{line-height:1.2;word-spacing:-.05em}
117 h1 strong,h2 strong,h3 strong,#toctitle strong,.sidebarblock>.content>.title strong,h4 strong,h5 strong,h6 strong{font-weight:400}
118 .clearfix::before,.clearfix::after,.float-group::before,.float-group::after{content:" ";display:table}
119 .clearfix::after,.float-group::after{clear:both}
120 *:not(pre)>code{font-size:.9375em;font-style:normal!important;letter-spacing:0;padding:.1em .5ex;word-spacing:-.15em;background-color:#f7f7f8;-webkit-border-radius:4px;border-radius:4px;line-height:1.45;text-rendering:optimizeSpeed;word-wrap:break-word}
121 *:not(pre)>code.nobreak{word-wrap:normal}
122 *:not(pre)>code.nowrap{white-space:nowrap}
123 pre,pre>code{line-height:1.45;color:rgba(0,0,0,.9);font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;text-rendering:optimizeSpeed}
124 em em{font-style:normal}
125 strong strong{font-weight:400}
126 .keyseq{color:rgba(51,51,51,.8)}
127 kbd{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;display:inline-block;color:rgba(0,0,0,.8);font-size:.65em;line-height:1.45;background-color:#f7f7f7;border:1px solid #ccc;-webkit-border-radius:3px;border-radius:3px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em white inset;box-shadow:0 1px 0 rgba(0,0,0,.2),0 0 0 .1em #fff inset;margin:0 .15em;padding:.2em .5em;vertical-align:middle;position:relative;top:-.1em;white-space:nowrap}
128 .keyseq kbd:first-child{margin-left:0}
129 .keyseq kbd:last-child{margin-right:0}
130 .menuseq,.menuref{color:#000}
131 .menuseq b:not(.caret),.menuref{font-weight:inherit}
132 .menuseq{word-spacing:-.02em}
133 .menuseq b.caret{font-size:1.25em;line-height:.8}
134 .menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
135 b.button::before,b.button::after{position:relative;top:-1px;font-weight:400}
136 b.button::before{content:"[";padding:0 3px 0 2px}
137 b.button::after{content:"]";padding:0 2px 0 3px}
138 p a>code:hover{color:rgba(0,0,0,.9)}
139 #header,#content,#footnotes,#footer{width:100%;margin-left:auto;margin-right:auto;margin-top:0;margin-bottom:0;max-width:62.5em;*zoom:1;position:relative;padding-left:.9375em;padding-right:.9375em}
140 #header::before,#header::after,#content::before,#content::after,#footnotes::before,#footnotes::after,#footer::before,#footer::after{content:" ";display:table}
141 #header::after,#content::after,#footnotes::after,#footer::after{clear:both}
142 #content{margin-top:1.25em}
143 #content::before{content:none}
144 #header>h1:first-child{color:rgba(0,0,0,.85);margin-top:2.25rem;margin-bottom:0}
145 #header>h1:first-child+#toc{margin-top:8px;border-top:1px solid #dddddf}
146 #header>h1:only-child,body.toc2 #header>h1:nth-last-child(2){border-bottom:1px solid #dddddf;padding-bottom:8px}
147 #header .details{border-bottom:1px solid #dddddf;line-height:1.45;padding-top:.25em;padding-bottom:.25em;padding-left:.25em;color:rgba(0,0,0,.6);display:-ms-flexbox;display:-webkit-flex;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap}
148 #header .details span:first-child{margin-left:-.125em}
149 #header .details span.email a{color:rgba(0,0,0,.85)}
150 #header .details br{display:none}
151 #header .details br+span::before{content:"\00a0\2013\00a0"}
152 #header .details br+span.author::before{content:"\00a0\22c5\00a0";color:rgba(0,0,0,.85)}
153 #header .details br+span#revremark::before{content:"\00a0|\00a0"}
154 #header #revnumber{text-transform:capitalize}
155 #header #revnumber::after{content:"\00a0"}
156 #content>h1:first-child:not([class]){color:rgba(0,0,0,.85);border-bottom:1px solid #dddddf;padding-bottom:8px;margin-top:0;padding-top:1rem;margin-bottom:1.25rem}
157 #toc{border-bottom:1px solid #e7e7e9;padding-bottom:.5em}
158 #toc>ul{margin-left:.125em}
159 #toc ul.sectlevel0>li>a{font-style:italic}
160 #toc ul.sectlevel0 ul.sectlevel1{margin:.5em 0}
161 #toc ul{font-family:"Open Sans","DejaVu Sans",sans-serif;list-style-type:none}
162 #toc li{line-height:1.3334;margin-top:.3334em}
163 #toc a{text-decoration:none}
164 #toc a:active{text-decoration:underline}
165 #toctitle{color:#7a2518;font-size:1.2em}
166 @media screen and (min-width:768px){#toctitle{font-size:1.375em}
167 body.toc2{padding-left:15em;padding-right:0}
168 #toc.toc2{margin-top:0!important;background-color:#f8f8f7;position:fixed;width:15em;left:0;top:0;border-right:1px solid #e7e7e9;border-top-width:0!important;border-bottom-width:0!important;z-index:1000;padding:1.25em 1em;height:100%;overflow:auto}
169 #toc.toc2 #toctitle{margin-top:0;margin-bottom:.8rem;font-size:1.2em}
170 #toc.toc2>ul{font-size:.9em;margin-bottom:0}
171 #toc.toc2 ul ul{margin-left:0;padding-left:1em}
172 #toc.toc2 ul.sectlevel0 ul.sectlevel1{padding-left:0;margin-top:.5em;margin-bottom:.5em}
173 body.toc2.toc-right{padding-left:0;padding-right:15em}
174 body.toc2.toc-right #toc.toc2{border-right-width:0;border-left:1px solid #e7e7e9;left:auto;right:0}}
175 @media screen and (min-width:1280px){body.toc2{padding-left:20em;padding-right:0}
176 #toc.toc2{width:20em}
177 #toc.toc2 #toctitle{font-size:1.375em}
178 #toc.toc2>ul{font-size:.95em}
179 #toc.toc2 ul ul{padding-left:1.25em}
180 body.toc2.toc-right{padding-left:0;padding-right:20em}}
181 #content #toc{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
182 #content #toc>:first-child{margin-top:0}
183 #content #toc>:last-child{margin-bottom:0}
184 #footer{max-width:100%;background-color:rgba(0,0,0,.8);padding:1.25em}
185 #footer-text{color:rgba(255,255,255,.8);line-height:1.44}
186 #content{margin-bottom:.625em}
187 .sect1{padding-bottom:.625em}
188 @media screen and (min-width:768px){#content{margin-bottom:1.25em}
189 .sect1{padding-bottom:1.25em}}
190 .sect1:last-child{padding-bottom:0}
191 .sect1+.sect1{border-top:1px solid #e7e7e9}
192 #content h1>a.anchor,h2>a.anchor,h3>a.anchor,#toctitle>a.anchor,.sidebarblock>.content>.title>a.anchor,h4>a.anchor,h5>a.anchor,h6>a.anchor{position:absolute;z-index:1001;width:1.5ex;margin-left:-1.5ex;display:block;text-decoration:none!important;visibility:hidden;text-align:center;font-weight:400}
193 #content h1>a.anchor::before,h2>a.anchor::before,h3>a.anchor::before,#toctitle>a.anchor::before,.sidebarblock>.content>.title>a.anchor::before,h4>a.anchor::before,h5>a.anchor::before,h6>a.anchor::before{content:"\00A7";font-size:.85em;display:block;padding-top:.1em}
194 #content h1:hover>a.anchor,#content h1>a.anchor:hover,h2:hover>a.anchor,h2>a.anchor:hover,h3:hover>a.anchor,#toctitle:hover>a.anchor,.sidebarblock>.content>.title:hover>a.anchor,h3>a.anchor:hover,#toctitle>a.anchor:hover,.sidebarblock>.content>.title>a.anchor:hover,h4:hover>a.anchor,h4>a.anchor:hover,h5:hover>a.anchor,h5>a.anchor:hover,h6:hover>a.anchor,h6>a.anchor:hover{visibility:visible}
195 #content h1>a.link,h2>a.link,h3>a.link,#toctitle>a.link,.sidebarblock>.content>.title>a.link,h4>a.link,h5>a.link,h6>a.link{color:#ba3925;text-decoration:none}
196 #content h1>a.link:hover,h2>a.link:hover,h3>a.link:hover,#toctitle>a.link:hover,.sidebarblock>.content>.title>a.link:hover,h4>a.link:hover,h5>a.link:hover,h6>a.link:hover{color:#a53221}
197 .audioblock,.imageblock,.literalblock,.listingblock,.stemblock,.videoblock{margin-bottom:1.25em}
198 .admonitionblock td.content>.title,.audioblock>.title,.exampleblock>.title,.imageblock>.title,.listingblock>.title,.literalblock>.title,.stemblock>.title,.openblock>.title,.paragraph>.title,.quoteblock>.title,table.tableblock>.title,.verseblock>.title,.videoblock>.title,.dlist>.title,.olist>.title,.ulist>.title,.qlist>.title,.hdlist>.title{text-rendering:optimizeLegibility;text-align:left;font-family:"Noto Serif","DejaVu Serif",serif;font-size:1rem;font-style:italic}
199 table.tableblock.fit-content>caption.title{white-space:nowrap;width:0}
200 .paragraph.lead>p,#preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:1.21875em;line-height:1.6;color:rgba(0,0,0,.85)}
201 table.tableblock #preamble>.sectionbody>[class="paragraph"]:first-of-type p{font-size:inherit}
202 .admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
203 .admonitionblock>table td.icon{text-align:center;width:80px}
204 .admonitionblock>table td.icon img{max-width:none}
205 .admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
206 .admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #dddddf;color:rgba(0,0,0,.6)}
207 .admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
208 .exampleblock>.content{border-style:solid;border-width:1px;border-color:#e6e6e6;margin-bottom:1.25em;padding:1.25em;background:#fff;-webkit-border-radius:4px;border-radius:4px}
209 .exampleblock>.content>:first-child{margin-top:0}
210 .exampleblock>.content>:last-child{margin-bottom:0}
211 .sidebarblock{border-style:solid;border-width:1px;border-color:#e0e0dc;margin-bottom:1.25em;padding:1.25em;background:#f8f8f7;-webkit-border-radius:4px;border-radius:4px}
212 .sidebarblock>:first-child{margin-top:0}
213 .sidebarblock>:last-child{margin-bottom:0}
214 .sidebarblock>.content>.title{color:#7a2518;margin-top:0;text-align:center}
215 .exampleblock>.content>:last-child>:last-child,.exampleblock>.content .olist>ol>li:last-child>:last-child,.exampleblock>.content .ulist>ul>li:last-child>:last-child,.exampleblock>.content .qlist>ol>li:last-child>:last-child,.sidebarblock>.content>:last-child>:last-child,.sidebarblock>.content .olist>ol>li:last-child>:last-child,.sidebarblock>.content .ulist>ul>li:last-child>:last-child,.sidebarblock>.content .qlist>ol>li:last-child>:last-child{margin-bottom:0}
216 .literalblock pre,.listingblock pre:not(.highlight),.listingblock pre[class="highlight"],.listingblock pre[class^="highlight "],.listingblock pre.CodeRay,.listingblock pre.prettyprint{background:#f7f7f8}
217 .sidebarblock .literalblock pre,.sidebarblock .listingblock pre:not(.highlight),.sidebarblock .listingblock pre[class="highlight"],.sidebarblock .listingblock pre[class^="highlight "],.sidebarblock .listingblock pre.CodeRay,.sidebarblock .listingblock pre.prettyprint{background:#f2f1f1}
218 .literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{-webkit-border-radius:4px;border-radius:4px;word-wrap:break-word;overflow-x:auto;padding:1em;font-size:.8125em}
219 @media screen and (min-width:768px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:.90625em}}
220 @media screen and (min-width:1280px){.literalblock pre,.literalblock pre[class],.listingblock pre,.listingblock pre[class]{font-size:1em}}
221 .literalblock pre.nowrap,.literalblock pre.nowrap pre,.listingblock pre.nowrap,.listingblock pre.nowrap pre{white-space:pre;word-wrap:normal}
222 .literalblock.output pre{color:#f7f7f8;background-color:rgba(0,0,0,.9)}
223 .listingblock pre.highlightjs{padding:0}
224 .listingblock pre.highlightjs>code{padding:1em;-webkit-border-radius:4px;border-radius:4px}
225 .listingblock pre.prettyprint{border-width:0}
226 .listingblock>.content{position:relative}
227 .listingblock code[data-lang]::before{display:none;content:attr(data-lang);position:absolute;font-size:.75em;top:.425rem;right:.5rem;line-height:1;text-transform:uppercase;color:#999}
228 .listingblock:hover code[data-lang]::before{display:block}
229 .listingblock.terminal pre .command::before{content:attr(data-prompt);padding-right:.5em;color:#999}
230 .listingblock.terminal pre .command:not([data-prompt])::before{content:"$"}
231 table.pyhltable{border-collapse:separate;border:0;margin-bottom:0;background:none}
232 table.pyhltable td{vertical-align:top;padding-top:0;padding-bottom:0;line-height:1.45}
233 table.pyhltable td.code{padding-left:.75em;padding-right:0}
234 pre.pygments .lineno,table.pyhltable td:not(.code){color:#999;padding-left:0;padding-right:.5em;border-right:1px solid #dddddf}
235 pre.pygments .lineno{display:inline-block;margin-right:.25em}
236 table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
237 .quoteblock{margin:0 1em 1.25em 1.5em;display:table}
238 .quoteblock>.title{margin-left:-1.5em;margin-bottom:.75em}
239 .quoteblock blockquote,.quoteblock p{color:rgba(0,0,0,.85);font-size:1.15rem;line-height:1.75;word-spacing:.1em;letter-spacing:0;font-style:italic;text-align:justify}
240 .quoteblock blockquote{margin:0;padding:0;border:0}
241 .quoteblock blockquote::before{content:"\201c";float:left;font-size:2.75em;font-weight:bold;line-height:.6em;margin-left:-.6em;color:#7a2518;text-shadow:0 1px 2px rgba(0,0,0,.1)}
242 .quoteblock blockquote>.paragraph:last-child p{margin-bottom:0}
243 .quoteblock .attribution{margin-top:.75em;margin-right:.5ex;text-align:right}
244 .verseblock{margin:0 1em 1.25em}
245 .verseblock pre{font-family:"Open Sans","DejaVu Sans",sans;font-size:1.15rem;color:rgba(0,0,0,.85);font-weight:300;text-rendering:optimizeLegibility}
246 .verseblock pre strong{font-weight:400}
247 .verseblock .attribution{margin-top:1.25rem;margin-left:.5ex}
248 .quoteblock .attribution,.verseblock .attribution{font-size:.9375em;line-height:1.45;font-style:italic}
249 .quoteblock .attribution br,.verseblock .attribution br{display:none}
250 .quoteblock .attribution cite,.verseblock .attribution cite{display:block;letter-spacing:-.025em;color:rgba(0,0,0,.6)}
251 .quoteblock.abstract blockquote::before,.quoteblock.excerpt blockquote::before,.quoteblock .quoteblock blockquote::before{display:none}
252 .quoteblock.abstract blockquote,.quoteblock.abstract p,.quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{line-height:1.6;word-spacing:0}
253 .quoteblock.abstract{margin:0 1em 1.25em;display:block}
254 .quoteblock.abstract>.title{margin:0 0 .375em;font-size:1.15em;text-align:center}
255 .quoteblock.excerpt,.quoteblock .quoteblock{margin:0 0 1.25em;padding:0 0 .25em 1em;border-left:.25em solid #dddddf}
256 .quoteblock.excerpt blockquote,.quoteblock.excerpt p,.quoteblock .quoteblock blockquote,.quoteblock .quoteblock p{color:inherit;font-size:1.0625rem}
257 .quoteblock.excerpt .attribution,.quoteblock .quoteblock .attribution{color:inherit;text-align:left;margin-right:0}
258 table.tableblock{max-width:100%;border-collapse:separate}
259 p.tableblock:last-child{margin-bottom:0}
260 td.tableblock>.content{margin-bottom:-1.25em}
261 table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
262 table.grid-all>thead>tr>.tableblock,table.grid-all>tbody>tr>.tableblock{border-width:0 1px 1px 0}
263 table.grid-all>tfoot>tr>.tableblock{border-width:1px 1px 0 0}
264 table.grid-cols>*>tr>.tableblock{border-width:0 1px 0 0}
265 table.grid-rows>thead>tr>.tableblock,table.grid-rows>tbody>tr>.tableblock{border-width:0 0 1px}
266 table.grid-rows>tfoot>tr>.tableblock{border-width:1px 0 0}
267 table.grid-all>*>tr>.tableblock:last-child,table.grid-cols>*>tr>.tableblock:last-child{border-right-width:0}
268 table.grid-all>tbody>tr:last-child>.tableblock,table.grid-all>thead:last-child>tr>.tableblock,table.grid-rows>tbody>tr:last-child>.tableblock,table.grid-rows>thead:last-child>tr>.tableblock{border-bottom-width:0}
269 table.frame-all{border-width:1px}
270 table.frame-sides{border-width:0 1px}
271 table.frame-topbot,table.frame-ends{border-width:1px 0}
272 table.stripes-all tr,table.stripes-odd tr:nth-of-type(odd){background:#f8f8f7}
273 table.stripes-none tr,table.stripes-odd tr:nth-of-type(even){background:none}
274 th.halign-left,td.halign-left{text-align:left}
275 th.halign-right,td.halign-right{text-align:right}
276 th.halign-center,td.halign-center{text-align:center}
277 th.valign-top,td.valign-top{vertical-align:top}
278 th.valign-bottom,td.valign-bottom{vertical-align:bottom}
279 th.valign-middle,td.valign-middle{vertical-align:middle}
280 table thead th,table tfoot th{font-weight:bold}
281 tbody tr th{display:table-cell;line-height:1.6;background:#f7f8f7}
282 tbody tr th,tbody tr th p,tfoot tr th,tfoot tr th p{color:rgba(0,0,0,.8);font-weight:bold}
283 p.tableblock>code:only-child{background:none;padding:0}
284 p.tableblock{font-size:1em}
285 td>div.verse{white-space:pre}
286 ol{margin-left:1.75em}
287 ul li ol{margin-left:1.5em}
288 dl dd{margin-left:1.125em}
289 dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
290 ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
291 ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
292 ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
293 ul.unstyled,ol.unstyled{margin-left:0}
294 ul.checklist{margin-left:.625em}
295 ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1.25em;font-size:.8em;position:relative;bottom:.125em}
296 ul.checklist li>p:first-child>input[type="checkbox"]:first-child{margin-right:.25em}
297 ul.inline{display:-ms-flexbox;display:-webkit-box;display:flex;-ms-flex-flow:row wrap;-webkit-flex-flow:row wrap;flex-flow:row wrap;list-style:none;margin:0 0 .625em -1.25em}
298 ul.inline>li{margin-left:1.25em}
299 .unstyled dl dt{font-weight:400;font-style:normal}
300 ol.arabic{list-style-type:decimal}
301 ol.decimal{list-style-type:decimal-leading-zero}
302 ol.loweralpha{list-style-type:lower-alpha}
303 ol.upperalpha{list-style-type:upper-alpha}
304 ol.lowerroman{list-style-type:lower-roman}
305 ol.upperroman{list-style-type:upper-roman}
306 ol.lowergreek{list-style-type:lower-greek}
307 .hdlist>table,.colist>table{border:0;background:none}
308 .hdlist>table>tbody>tr,.colist>table>tbody>tr{background:none}
309 td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
310 td.hdlist1{font-weight:bold;padding-bottom:1.25em}
311 .literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
312 .colist td:not([class]):first-child{padding:.4em .75em 0;line-height:1;vertical-align:top}
313 .colist td:not([class]):first-child img{max-width:none}
314 .colist td:not([class]):last-child{padding:.25em 0}
315 .thumb,.th{line-height:0;display:inline-block;border:solid 4px #fff;-webkit-box-shadow:0 0 0 1px #ddd;box-shadow:0 0 0 1px #ddd}
316 .imageblock.left{margin:.25em .625em 1.25em 0}
317 .imageblock.right{margin:.25em 0 1.25em .625em}
318 .imageblock>.title{margin-bottom:0}
319 .imageblock.thumb,.imageblock.th{border-width:6px}
320 .imageblock.thumb>.title,.imageblock.th>.title{padding:0 .125em}
321 .image.left,.image.right{margin-top:.25em;margin-bottom:.25em;display:inline-block;line-height:0}
322 .image.left{margin-right:.625em}
323 .image.right{margin-left:.625em}
324 a.image{text-decoration:none;display:inline-block}
325 a.image object{pointer-events:none}
326 sup.footnote,sup.footnoteref{font-size:.875em;position:static;vertical-align:super}
327 sup.footnote a,sup.footnoteref a{text-decoration:none}
328 sup.footnote a:active,sup.footnoteref a:active{text-decoration:underline}
329 #footnotes{padding-top:.75em;padding-bottom:.75em;margin-bottom:.625em}
330 #footnotes hr{width:20%;min-width:6.25em;margin:-.25em 0 .75em;border-width:1px 0 0}
331 #footnotes .footnote{padding:0 .375em 0 .225em;line-height:1.3334;font-size:.875em;margin-left:1.2em;margin-bottom:.2em}
332 #footnotes .footnote a:first-of-type{font-weight:bold;text-decoration:none;margin-left:-1.05em}
333 #footnotes .footnote:last-of-type{margin-bottom:0}
334 #content #footnotes{margin-top:-.625em;margin-bottom:0;padding:.75em 0}
335 .gist .file-data>table{border:0;background:#fff;width:100%;margin-bottom:0}
336 .gist .file-data>table td.line-data{width:99%}
337 div.unbreakable{page-break-inside:avoid}
338 .big{font-size:larger}
339 .small{font-size:smaller}
340 .underline{text-decoration:underline}
341 .overline{text-decoration:overline}
342 .line-through{text-decoration:line-through}
344 .aqua-background{background-color:#00fafa}
346 .black-background{background-color:#000}
348 .blue-background{background-color:#0000fa}
349 .fuchsia{color:#bf00bf}
350 .fuchsia-background{background-color:#fa00fa}
352 .gray-background{background-color:#7d7d7d}
353 .green{color:#006000}
354 .green-background{background-color:#007d00}
356 .lime-background{background-color:#00fa00}
357 .maroon{color:#600000}
358 .maroon-background{background-color:#7d0000}
360 .navy-background{background-color:#00007d}
361 .olive{color:#606000}
362 .olive-background{background-color:#7d7d00}
363 .purple{color:#600060}
364 .purple-background{background-color:#7d007d}
366 .red-background{background-color:#fa0000}
367 .silver{color:#909090}
368 .silver-background{background-color:#bcbcbc}
370 .teal-background{background-color:#007d7d}
371 .white{color:#bfbfbf}
372 .white-background{background-color:#fafafa}
373 .yellow{color:#bfbf00}
374 .yellow-background{background-color:#fafa00}
375 span.icon>.fa{cursor:default}
376 a span.icon>.fa{cursor:inherit}
377 .admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
378 .admonitionblock td.icon .icon-note::before{content:"\f05a";color:#19407c}
379 .admonitionblock td.icon .icon-tip::before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
380 .admonitionblock td.icon .icon-warning::before{content:"\f071";color:#bf6900}
381 .admonitionblock td.icon .icon-caution::before{content:"\f06d";color:#bf3400}
382 .admonitionblock td.icon .icon-important::before{content:"\f06a";color:#bf0000}
383 .conum[data-value]{display:inline-block;color:#fff!important;background-color:rgba(0,0,0,.8);-webkit-border-radius:100px;border-radius:100px;text-align:center;font-size:.75em;width:1.67em;height:1.67em;line-height:1.67em;font-family:"Open Sans","DejaVu Sans",sans-serif;font-style:normal;font-weight:bold}
384 .conum[data-value] *{color:#fff!important}
385 .conum[data-value]+b{display:none}
386 .conum[data-value]::after{content:attr(data-value)}
387 pre .conum[data-value]{position:relative;top:-.125em}
388 b.conum *{color:inherit!important}
389 .conum:not([data-value]):empty{display:none}
390 dt,th.tableblock,td.content,div.footnote{text-rendering:optimizeLegibility}
391 h1,h2,p,td.content,span.alt{letter-spacing:-.01em}
392 p strong,td.content strong,div.footnote strong{letter-spacing:-.005em}
393 p,blockquote,dt,td.content,span.alt{font-size:1.0625rem}
394 p{margin-bottom:1.25rem}
395 .sidebarblock p,.sidebarblock dt,.sidebarblock td.content,p.tableblock{font-size:1em}
396 .exampleblock>.content{background-color:#fffef7;border-color:#e0e0dc;-webkit-box-shadow:0 1px 4px #e0e0dc;box-shadow:0 1px 4px #e0e0dc}
397 .print-only{display:none!important}
398 @page{margin:1.25cm .75cm}
399 @media print{*{-webkit-box-shadow:none!important;box-shadow:none!important;text-shadow:none!important}
401 a{color:inherit!important;text-decoration:underline!important}
402 a.bare,a[href^="#"],a[href^="mailto:"]{text-decoration:none!important}
403 a[href^="http:"]:not(.bare)::after,a[href^="https:"]:not(.bare)::after{content:"(" attr(href) ")";display:inline-block;font-size:.875em;padding-left:.25em}
404 abbr[title]::after{content:" (" attr(title) ")"}
405 pre,blockquote,tr,img,object,svg{page-break-inside:avoid}
406 thead{display:table-header-group}
408 p,blockquote,dt,td.content{font-size:1em;orphans:3;widows:3}
409 h2,h3,#toctitle,.sidebarblock>.content>.title{page-break-after:avoid}
410 #toc,.sidebarblock,.exampleblock>.content{background:none!important}
411 #toc{border-bottom:1px solid #dddddf!important;padding-bottom:0!important}
412 body.book #header{text-align:center}
413 body.book #header>h1:first-child{border:0!important;margin:2.5em 0 1em}
414 body.book #header .details{border:0!important;display:block;padding:0!important}
415 body.book #header .details span:first-child{margin-left:0!important}
416 body.book #header .details br{display:block}
417 body.book #header .details br+span::before{content:none!important}
418 body.book #toc{border:0!important;text-align:left!important;padding:0!important;margin:0!important}
419 body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-break-before:always}
420 .listingblock code[data-lang]::before{display:block}
421 #footer{padding:0 .9375em}
422 .hide-on-print{display:none!important}
423 .print-only{display:block!important}
424 .hide-for-print{display:none!important}
425 .show-for-print{display:inherit!important}}
426 @media print,amzn-kf8{#header>h1:first-child{margin-top:1.25rem}
427 .sect1{padding:0!important}
428 .sect1+.sect1{border:0}
429 #footer{background:none}
430 #footer-text{color:rgba(0,0,0,.6);font-size:.9em}}
431 @media amzn-kf8{#header,#content,#footnotes,#footer{padding:0}}
434 <body class="article toc2 toc-left">
436 <h1>Boost.Mp11: A C++11 metaprogramming library</h1>
437 <div class="details">
438 <span id="author" class="author">Peter Dimov</span><br>
440 <div id="toc" class="toc2">
441 <div id="toctitle">Table of Contents</div>
442 <ul class="sectlevel1">
443 <li><a href="#overview">Overview</a></li>
444 <li><a href="#definitions">Definitions</a></li>
445 <li><a href="#examples">Examples</a>
446 <ul class="sectlevel2">
447 <li><a href="#generating_test_cases">Generating Test Cases</a></li>
448 <li><a href="#writing_common_type_specializations">Writing common_type Specializations</a></li>
449 <li><a href="#fixing_tuple_cat">Fixing tuple_cat</a></li>
450 <li><a href="#computing_return_types">Computing Return Types</a></li>
453 <li><a href="#changelog">Revision History</a>
454 <ul class="sectlevel2">
455 <li><a href="#changes_in_1_70_0">Changes in 1.70.0</a></li>
456 <li><a href="#changes_in_1_69_0">Changes in 1.69.0</a></li>
459 <li><a href="#reference">Reference</a>
460 <ul class="sectlevel2">
461 <li><a href="#integral">Integral Constants, <boost/mp11/integral.hpp></a>
462 <ul class="sectlevel3">
463 <li><a href="#mp_boolb">mp_bool<B></a></li>
464 <li><a href="#mp_true">mp_true</a></li>
465 <li><a href="#mp_false">mp_false</a></li>
466 <li><a href="#mp_to_boolt">mp_to_bool<T></a></li>
467 <li><a href="#mp_nott">mp_not<T></a></li>
468 <li><a href="#mp_inti">mp_int<I></a></li>
469 <li><a href="#mp_size_tn">mp_size_t<N></a></li>
472 <li><a href="#list">List Operations, <boost/mp11/list.hpp></a>
473 <ul class="sectlevel3">
474 <li><a href="#mp_listt">mp_list<T…​></a></li>
475 <li><a href="#mp_list_ct_i">mp_list_c<T, I…​></a></li>
476 <li><a href="#mp_is_listl">mp_is_list<L></a></li>
477 <li><a href="#mp_sizel">mp_size<L></a></li>
478 <li><a href="#mp_emptyl">mp_empty<L></a></li>
479 <li><a href="#mp_assignl1_l2">mp_assign<L1, L2></a></li>
480 <li><a href="#mp_clearl">mp_clear<L></a></li>
481 <li><a href="#mp_frontl">mp_front<L></a></li>
482 <li><a href="#mp_pop_frontl">mp_pop_front<L></a></li>
483 <li><a href="#mp_firstl">mp_first<L></a></li>
484 <li><a href="#mp_restl">mp_rest<L></a></li>
485 <li><a href="#mp_secondl">mp_second<L></a></li>
486 <li><a href="#mp_thirdl">mp_third<L></a></li>
487 <li><a href="#mp_push_frontl_t">mp_push_front<L, T…​></a></li>
488 <li><a href="#mp_push_backl_t">mp_push_back<L, T…​></a></li>
489 <li><a href="#mp_renamel_y">mp_rename<L, Y></a></li>
490 <li><a href="#mp_applyf_l">mp_apply<F, L></a></li>
491 <li><a href="#mp_apply_qq_l">mp_apply_q<Q, L></a></li>
492 <li><a href="#mp_appendl">mp_append<L…​></a></li>
493 <li><a href="#mp_replace_frontl_t">mp_replace_front<L, T></a></li>
494 <li><a href="#mp_replace_firstl_t">mp_replace_first<L, T></a></li>
495 <li><a href="#mp_replace_secondl_t">mp_replace_second<L, T></a></li>
496 <li><a href="#mp_replace_thirdl_t">mp_replace_third<L, T></a></li>
497 <li><a href="#mp_transform_frontl_f">mp_transform_front<L, F></a></li>
498 <li><a href="#mp_transform_front_ql_q">mp_transform_front_q<L, Q></a></li>
499 <li><a href="#mp_transform_firstl_f">mp_transform_first<L, F></a></li>
500 <li><a href="#mp_transform_first_ql_q">mp_transform_first_q<L, Q></a></li>
501 <li><a href="#mp_transform_secondl_f">mp_transform_second<L, F></a></li>
502 <li><a href="#mp_transform_second_ql_q">mp_transform_second_q<L, Q></a></li>
503 <li><a href="#mp_transform_thirdl_f">mp_transform_third<L, F></a></li>
504 <li><a href="#mp_transform_third_ql_q">mp_transform_third_q<L, Q></a></li>
507 <li><a href="#utility">Utility Components, <boost/mp11/utility.hpp></a>
508 <ul class="sectlevel3">
509 <li><a href="#mp_identityt">mp_identity<T></a></li>
510 <li><a href="#mp_identity_tt">mp_identity_t<T></a></li>
511 <li><a href="#mp_inheritt">mp_inherit<T…​></a></li>
512 <li><a href="#mp_if_cc_t_e">mp_if_c<C, T, E…​></a></li>
513 <li><a href="#mp_ifc_t_e">mp_if<C, T, E…​></a></li>
514 <li><a href="#mp_eval_if_cc_t_f_u">mp_eval_if_c<C, T, F, U…​></a></li>
515 <li><a href="#mp_eval_ifc_t_f_u">mp_eval_if<C, T, F, U…​></a></li>
516 <li><a href="#mp_eval_if_qc_t_q_u">mp_eval_if_q<C, T, Q, U…​></a></li>
517 <li><a href="#mp_eval_if_notc_t_f_u">mp_eval_if_not<C, T, F, U…​></a></li>
518 <li><a href="#mp_eval_if_not_qc_t_q_u">mp_eval_if_not_q<C, T, Q, U…​></a></li>
519 <li><a href="#mp_validf_t">mp_valid<F, T…​></a></li>
520 <li><a href="#mp_valid_qq_t">mp_valid_q<Q, T…​></a></li>
521 <li><a href="#mp_eval_ort_f_u">mp_eval_or<T, F, U…​></a></li>
522 <li><a href="#mp_eval_or_qt_q_u">mp_eval_or_q<T, Q, U…​></a></li>
523 <li><a href="#mp_condc_t_r">mp_cond<C, T, R…​></a></li>
524 <li><a href="#mp_deferf_t">mp_defer<F, T…​></a></li>
525 <li><a href="#mp_quotef">mp_quote<F></a></li>
526 <li><a href="#mp_quote_traitf">mp_quote_trait<F></a></li>
527 <li><a href="#mp_invoke_qq_t">mp_invoke_q<Q, T…​></a></li>
528 <li><a href="#mp_not_fnp">mp_not_fn<P></a></li>
529 <li><a href="#mp_not_fn_qq">mp_not_fn_q<Q></a></li>
532 <li><a href="#algorithm">Algorithms, <boost/mp11/algorithm.hpp></a>
533 <ul class="sectlevel3">
534 <li><a href="#mp_transformf_l">mp_transform<F, L…​></a></li>
535 <li><a href="#mp_transform_qq_l">mp_transform_q<Q, L…​></a></li>
536 <li><a href="#mp_transform_ifp_f_l">mp_transform_if<P, F, L…​></a></li>
537 <li><a href="#mp_transform_if_qqp_qf_l">mp_transform_if_q<Qp, Qf, L…​></a></li>
538 <li><a href="#mp_filterp_l">mp_filter<P, L…​></a></li>
539 <li><a href="#mp_filter_qqp_l">mp_filter_q<Qp, L…​></a></li>
540 <li><a href="#mp_filll_v">mp_fill<L, V></a></li>
541 <li><a href="#mp_countl_v">mp_count<L, V></a></li>
542 <li><a href="#mp_count_ifl_p">mp_count_if<L, P></a></li>
543 <li><a href="#mp_count_if_ql_q">mp_count_if_q<L, Q></a></li>
544 <li><a href="#mp_containsl_v">mp_contains<L, V></a></li>
545 <li><a href="#mp_starts_withl1_l2">mp_starts_with<L1, L2></a></li>
546 <li><a href="#mp_repeat_cl_n">mp_repeat_c<L, N></a></li>
547 <li><a href="#mp_repeatl_n">mp_repeat<L, N></a></li>
548 <li><a href="#mp_productf_l">mp_product<F, L…​></a></li>
549 <li><a href="#mp_product_qq_l">mp_product_q<Q, L…​></a></li>
550 <li><a href="#mp_drop_cl_n">mp_drop_c<L, N></a></li>
551 <li><a href="#mp_dropl_n">mp_drop<L, N></a></li>
552 <li><a href="#mp_from_sequences">mp_from_sequence<S></a></li>
553 <li><a href="#mp_iota_cn">mp_iota_c<N></a></li>
554 <li><a href="#mp_iotan">mp_iota<N></a></li>
555 <li><a href="#mp_at_cl_i">mp_at_c<L, I></a></li>
556 <li><a href="#mp_atl_i">mp_at<L, I></a></li>
557 <li><a href="#mp_take_cl_n">mp_take_c<L, N></a></li>
558 <li><a href="#mp_takel_n">mp_take<L, N></a></li>
559 <li><a href="#mp_backl">mp_back<L></a></li>
560 <li><a href="#mp_pop_backl">mp_pop_back<L></a></li>
561 <li><a href="#mp_insert_cl_i_t">mp_insert_c<L, I, T…​></a></li>
562 <li><a href="#mp_insertl_i_t">mp_insert<L, I, T…​></a></li>
563 <li><a href="#mp_erase_cl_i_j">mp_erase_c<L, I, J></a></li>
564 <li><a href="#mp_erasel_i_j">mp_erase<L, I, J></a></li>
565 <li><a href="#mp_replacel_v_w">mp_replace<L, V, W></a></li>
566 <li><a href="#mp_replace_ifl_p_w">mp_replace_if<L, P, W></a></li>
567 <li><a href="#mp_replace_if_ql_q_w">mp_replace_if_q<L, Q, W></a></li>
568 <li><a href="#mp_replace_at_cl_i_w">mp_replace_at_c<L, I, W></a></li>
569 <li><a href="#mp_replace_atl_i_w">mp_replace_at<L, I, W></a></li>
570 <li><a href="#mp_copy_ifl_p">mp_copy_if<L, P></a></li>
571 <li><a href="#mp_copy_if_ql_q">mp_copy_if_q<L, Q></a></li>
572 <li><a href="#mp_removel_v">mp_remove<L, V></a></li>
573 <li><a href="#mp_remove_ifl_p">mp_remove_if<L, P></a></li>
574 <li><a href="#mp_remove_if_ql_q">mp_remove_if_q<L, Q></a></li>
575 <li><a href="#mp_partitionl_p">mp_partition<L, P></a></li>
576 <li><a href="#mp_partition_ql_q">mp_partition_q<L, Q></a></li>
577 <li><a href="#mp_sortl_p">mp_sort<L, P></a></li>
578 <li><a href="#mp_sort_ql_q">mp_sort_q<L, Q></a></li>
579 <li><a href="#mp_nth_element_cl_i_p">mp_nth_element_c<L, I, P></a></li>
580 <li><a href="#mp_nth_elementl_i_p">mp_nth_element<L, I, P></a></li>
581 <li><a href="#mp_nth_element_ql_i_q">mp_nth_element_q<L, I, Q></a></li>
582 <li><a href="#mp_min_elementl_p">mp_min_element<L, P></a></li>
583 <li><a href="#mp_min_element_ql_q">mp_min_element_q<L, Q></a></li>
584 <li><a href="#mp_max_elementl_p">mp_max_element<L, P></a></li>
585 <li><a href="#mp_max_element_ql_q">mp_max_element_q<L, Q></a></li>
586 <li><a href="#mp_findl_v">mp_find<L, V></a></li>
587 <li><a href="#mp_find_ifl_p">mp_find_if<L, P></a></li>
588 <li><a href="#mp_find_if_ql_q">mp_find_if_q<L, Q></a></li>
589 <li><a href="#mp_reversel">mp_reverse<L></a></li>
590 <li><a href="#mp_foldl_v_f">mp_fold<L, V, F></a></li>
591 <li><a href="#mp_fold_ql_v_q">mp_fold_q<L, V, Q></a></li>
592 <li><a href="#mp_reverse_foldl_v_f">mp_reverse_fold<L, V, F></a></li>
593 <li><a href="#mp_reverse_fold_ql_v_q">mp_reverse_fold_q<L, V, Q></a></li>
594 <li><a href="#mp_uniquel">mp_unique<L></a></li>
595 <li><a href="#mp_all_ofl_p">mp_all_of<L, P></a></li>
596 <li><a href="#mp_all_of_ql_q">mp_all_of_q<L, Q></a></li>
597 <li><a href="#mp_none_ofl_p">mp_none_of<L, P></a></li>
598 <li><a href="#mp_none_of_ql_q">mp_none_of_q<L, Q></a></li>
599 <li><a href="#mp_any_ofl_p">mp_any_of<L, P></a></li>
600 <li><a href="#mp_any_of_ql_q">mp_any_of_q<L, Q></a></li>
601 <li><a href="#mp_for_eachlf">mp_for_each<L>(f)</a></li>
602 <li><a href="#mp_with_indexni_f">mp_with_index<N>(i, f)</a></li>
605 <li><a href="#set">Set Operations, <boost/mp11/set.hpp></a>
606 <ul class="sectlevel3">
607 <li><a href="#mp_is_sets">mp_is_set<S></a></li>
608 <li><a href="#mp_set_containss_v">mp_set_contains<S, V></a></li>
609 <li><a href="#mp_set_push_backs_t">mp_set_push_back<S, T…​></a></li>
610 <li><a href="#mp_set_push_fronts_t">mp_set_push_front<S, T…​></a></li>
611 <li><a href="#mp_set_unionl">mp_set_union<L…​></a></li>
612 <li><a href="#mp_set_intersections">mp_set_intersection<S…​></a></li>
613 <li><a href="#mp_set_differencel_s">mp_set_difference<L, S…​></a></li>
616 <li><a href="#map">Map Operations, <boost/mp11/map.hpp></a>
617 <ul class="sectlevel3">
618 <li><a href="#mp_is_mapm">mp_is_map<M></a></li>
619 <li><a href="#mp_map_findm_k">mp_map_find<M, K></a></li>
620 <li><a href="#mp_map_containsm_k">mp_map_contains<M, K></a></li>
621 <li><a href="#mp_map_insertm_t">mp_map_insert<M, T></a></li>
622 <li><a href="#mp_map_replacem_t">mp_map_replace<M, T></a></li>
623 <li><a href="#mp_map_updatem_t_f">mp_map_update<M, T, F></a></li>
624 <li><a href="#mp_map_update_qm_t_q">mp_map_update_q<M, T, Q></a></li>
625 <li><a href="#mp_map_erasem_k">mp_map_erase<M, K></a></li>
626 <li><a href="#mp_map_keysm">mp_map_keys<M></a></li>
629 <li><a href="#function">Helper Metafunctions, <boost/mp11/function.hpp></a>
630 <ul class="sectlevel3">
631 <li><a href="#mp_voidt">mp_void<T…​></a></li>
632 <li><a href="#mp_andt">mp_and<T…​></a></li>
633 <li><a href="#mp_allt">mp_all<T…​></a></li>
634 <li><a href="#mp_ort">mp_or<T…​></a></li>
635 <li><a href="#mp_anyt">mp_any<T…​></a></li>
636 <li><a href="#mp_samet">mp_same<T…​></a></li>
637 <li><a href="#mp_similart">mp_similar<T…​></a></li>
638 <li><a href="#mp_plust">mp_plus<T…​></a></li>
639 <li><a href="#mp_lesst1_t2">mp_less<T1, T2></a></li>
640 <li><a href="#mp_mint1_t">mp_min<T1, T…​></a></li>
641 <li><a href="#mp_maxt1_t">mp_max<T1, T…​></a></li>
644 <li><a href="#bind">Bind, <boost/mp11/bind.hpp></a>
645 <ul class="sectlevel3">
646 <li><a href="#mp_argi">mp_arg<I></a></li>
647 <li><a href="#1_9">_1, …​, _9</a></li>
648 <li><a href="#mp_bindf_t">mp_bind<F, T…​></a></li>
649 <li><a href="#mp_bind_qq_t">mp_bind_q<Q, T…​></a></li>
650 <li><a href="#mp_bind_frontf_t">mp_bind_front<F, T…​></a></li>
651 <li><a href="#mp_bind_front_qq_t">mp_bind_front_q<Q, T…​></a></li>
652 <li><a href="#mp_bind_backf_t">mp_bind_back<F, T…​></a></li>
653 <li><a href="#mp_bind_back_qq_t">mp_bind_back_q<Q, T…​></a></li>
656 <li><a href="#integer_sequence">Integer Sequences, <boost/mp11/integer_sequence.hpp></a>
657 <ul class="sectlevel3">
658 <li><a href="#integer_sequencet_i">integer_sequence<T, I…​></a></li>
659 <li><a href="#make_integer_sequencet_n">make_integer_sequence<T, N></a></li>
660 <li><a href="#index_sequencei">index_sequence<I…​></a></li>
661 <li><a href="#make_index_sequencen">make_index_sequence<N></a></li>
662 <li><a href="#index_sequence_fort">index_sequence_for<T…​></a></li>
665 <li><a href="#tuple">Tuple Operations, <boost/mp11/tuple.hpp></a>
666 <ul class="sectlevel3">
667 <li><a href="#tuple_applyf_tp">tuple_apply(f, tp)</a></li>
668 <li><a href="#construct_from_tuplettp">construct_from_tuple<T>(tp)</a></li>
669 <li><a href="#tuple_for_eachtp_f">tuple_for_each(tp, f)</a></li>
672 <li><a href="#mp11">Convenience Header, <boost/mp11.hpp></a></li>
673 <li><a href="#mpl">MPL Support, <boost/mp11/mpl.hpp></a></li>
676 <li><a href="#copyright_license_and_acknowledgments">Appendix A: Copyright, License, and Acknowledgments</a></li>
682 <h2 id="overview">Overview</h2>
683 <div class="sectionbody">
684 <div class="paragraph">
685 <p>Mp11 is a C++11 metaprogramming library for compile-time manipulation of data structures
686 that contain types. It’s based on template aliases and variadic templates and implements the
687 approach outlined in the article
688 <a href="simple_cxx11_metaprogramming.html">"Simple C++ metaprogramming"</a>
689 and <a href="simple_cxx11_metaprogramming_2.html">its sequel</a>. Reading these
690 articles before proceeding with this documentation is <em>highly</em> recommended.</p>
692 <div class="paragraph">
693 <p>The general principles upon which Mp11 is built are that algorithms and metafunctions are
694 template aliases of the form <code>F<T…​></code> and data structures are lists of the form <code>L<T…​></code>,
695 with the library placing no requirements on <code>L</code>. <code>mp_list<T…​></code> is the built-in list type,
696 but <code>std::tuple<T…​></code>, <code>std::pair<T1, T2></code> and <code>std::variant<T…​></code> are also perfectly
697 legitimate list types, although of course <code>std::pair<T1, T2></code>, due to having exactly two elements,
698 is not resizeable and will consequently not work with algorithms that need to add or remove
701 <div class="paragraph">
702 <p>Another distinguishing feature of this approach is that lists (<code>L<T…​></code>) have the same form as
703 metafunctions (<code>F<T…​></code>) and can therefore be used as such. For example, applying <code>std::add_pointer_t</code>
704 to the list <code>std::tuple<int, float></code> by way of <code>mp_transform<std::add_pointer_t, std::tuple<int, float>></code>
705 gives us <code>std::tuple<int*, float*></code>, but we can also apply <code>mp_list</code> to the same tuple:</p>
707 <div class="literalblock">
708 <div class="content">
709 <pre>using R = mp_transform<mp_list, std::tuple<int, float>>;</pre>
712 <div class="paragraph">
713 <p>and get <code>std::tuple<mp_list<int>, mp_list<float>></code>.</p>
718 <h2 id="definitions">Definitions</h2>
719 <div class="sectionbody">
720 <div class="paragraph">
721 <p>A <em>list</em> is a — usually but not necessarily variadic — template class whose parameters are all types,
722 for example <code>mp_list<char[], void></code>, <code>mp_list<></code>, <code>std::tuple<int, float, char></code>, <code>std::pair<int, float></code>, <code>std::shared_ptr<X></code>.</p>
724 <div class="paragraph">
725 <p>A <em>metafunction</em> is a class template or a template alias whose parameters are all types, for example <code>std::add_pointer_t</code>,
726 <code>std::is_const</code>, <code>mp_second</code>, <code>mp_push_front</code>, <code>mp_list</code>, <code>std::tuple</code>, <code>std::pair</code>, <code>std::shared_ptr</code>, or</p>
728 <div class="listingblock">
729 <div class="content">
730 <pre class="highlight"><code>template<class...> using F1 = void;
732 template<class T> using F2 = T*;
734 template<class... T> using F3 = std::integral_constant<std::size_t, sizeof...(T)>;</code></pre>
737 <div class="paragraph">
738 <p>A <em>quoted metafunction</em> is a class with a public metafunction member called <code>fn</code>, for example</p>
740 <div class="listingblock">
741 <div class="content">
742 <pre class="highlight"><code>struct Q1 { template<class...> using fn = void; };
744 struct Q2 { template<class T> using fn = T*; };
746 struct Q3 { template<class... T> using fn =
747 std::integral_constant<std::size_t, sizeof...(T)>; };</code></pre>
750 <div class="paragraph">
751 <p>An <em>integral constant type</em> is a class with a public member <code>value</code> that is an integral constant in the C++ sense. For example,
752 <code>std::integral_constant<int, 7></code>, or</p>
754 <div class="literalblock">
755 <div class="content">
756 <pre>struct N { static int constexpr value = 2; };</pre>
759 <div class="paragraph">
760 <p>A <em>set</em> is a list whose elements are unique.</p>
762 <div class="paragraph">
763 <p>A <em>map</em> is a list of lists, the inner lists having at least one element (the key.) The keys of the map must be unique. For example,</p>
765 <div class="listingblock">
766 <div class="content">
767 <pre class="highlight"><code>using M1 = std::tuple<std::pair<int, int*>, std::pair<float, float*>,
768 std::pair<void, void*>>;
770 using M2 = mp_list<mp_list<int, int*>, mp_list<float>,
771 mp_list<char, char[1], char[2]>>;</code></pre>
777 <h2 id="examples">Examples</h2>
778 <div class="sectionbody">
780 <h3 id="generating_test_cases">Generating Test Cases</h3>
781 <div class="paragraph">
782 <p>Let’s suppose that we have written a metafunction <code>result<T, U></code>:</p>
784 <div class="listingblock">
785 <div class="content">
786 <pre class="highlight"><code>template<class T> using promote = typename std::common_type<T, int>::type;
788 template<class T, class U> using result =
789 typename std::common_type<promote<T>, promote<U>>::type;</code></pre>
792 <div class="paragraph">
793 <p>that ought to represent the result of an arithmetic operation on the integer types <code>T</code> and <code>U</code>,
794 for example <code>t + u</code>. We want to test whether <code>result<T, U></code> gives correct results for various combinations
795 of <code>T</code> and <code>U</code>, so we write the function</p>
797 <div class="listingblock">
798 <div class="content">
799 <pre class="highlight"><code>template<class T1, class T2> void test_result()
801 using T3 = decltype( T1() + T2() );
802 using T4 = result<T1, T2>;
804 std::cout << ( std::is_same<T3, T4>::value? "[PASS]": "[FAIL]" ) << std::endl;
808 <div class="paragraph">
809 <p>and then need to call it a substantial number of times:</p>
811 <div class="literalblock">
812 <div class="content">
815 test_result<char, char>();
816 test_result<char, short>();
817 test_result<char, int>();
818 test_result<char, unsigned>();
823 <div class="paragraph">
824 <p>Writing all those type combinations by hand is unwieldy, error prone, and worst of all, boring. This is
825 how we can leverage Mp11 to automate the task:</p>
827 <div class="listingblock">
828 <div class="content">
829 <pre class="highlight"><code>#include <boost/mp11.hpp>
830 #include <boost/core/demangle.hpp>
831 #include <type_traits>
832 #include <iostream>
833 #include <typeinfo>
835 using namespace boost::mp11;
837 template<class T> std::string name()
839 return boost::core::demangle( typeid(T).name() );
842 template<class T> using promote = typename std::common_type<T, int>::type;
844 template<class T, class U> using result =
845 typename std::common_type<promote<T>, promote<U>>::type;
847 template<class T1, class T2> void test_result( mp_list<T1, T2> const& )
849 using T3 = decltype( T1() + T2() );
850 using T4 = result<T1, T2>;
852 std::cout << ( std::is_same<T3, T4>::value? "[PASS] ": "[FAIL] " )
853 << name<T1>() << " + " << name<T2>() << " -> " << name<T3>()
854 << ", result: " << name<T4>() << std::endl;
859 using L = std::tuple<char, short, int, unsigned, long, unsigned long>;
860 tuple_for_each( mp_product<mp_list, L, L>(), [](auto&& x){ test_result(x); } );
864 <div class="paragraph">
865 <p>How does it work?</p>
867 <div class="paragraph">
868 <p><code>mp_product<F, L1, L2></code> calls <code>F<T1, T2></code> where <code>T1</code> varies over the elements of <code>L1</code> and <code>T2</code> varies over
869 the elements of <code>L2</code>, as if by executing two nested loops. It then returns a list of these results, of the same
870 type as <code>L1</code>.</p>
872 <div class="paragraph">
873 <p>In our case, both lists are the same <code>std::tuple</code>, and <code>F</code> is <code>mp_list</code>, so <code>mp_product<mp_list, L, L></code> will get us
874 <code>std::tuple<mp_list<char, char>, mp_list<char, short>, mp_list<char, int>, …​, mp_list<unsigned long, long>, mp_list<unsigned long, unsigned long>></code>.</p>
876 <div class="paragraph">
877 <p>We then default-construct this tuple and pass it to <code>tuple_for_each</code>. <code>tuple_for_each(tp, f)</code> calls <code>f</code> for every
878 tuple element; we use a (C++14) lambda that calls <code>test_result</code>.</p>
880 <div class="paragraph">
881 <p>In pure C++11, we can’t use a lambda with an <code>auto&&</code> parameter, so we’ll have to make <code>test_result</code> a function object with
882 a templated <code>operator()</code> and pass that to <code>tuple_for_each</code> directly:</p>
884 <div class="listingblock">
885 <div class="content">
886 <pre class="highlight"><code>struct test_result
888 template<class T1, class T2> void operator()( mp_list<T1, T2> const& ) const
890 using T3 = decltype( T1() + T2() );
891 using T4 = result<T1, T2>;
893 std::cout << ( std::is_same<T3, T4>::value? "[PASS] ": "[FAIL] " )
894 << name<T1>() << " + " << name<T2>() << " -> " << name<T3>()
895 << ", result: " << name<T4>() << std::endl;
901 using L = std::tuple<char, short, int, unsigned, long, unsigned long>;
902 tuple_for_each( mp_product<mp_list, L, L>(), test_result() );
908 <h3 id="writing_common_type_specializations">Writing common_type Specializations</h3>
909 <div class="paragraph">
910 <p>The standard trait <code>std::common_type</code>, used to obtain a type to which all of its arguments can convert without
911 unnecessary loss of precision, can be user-specialized when its default implementation (based on the ternary <code>?:</code>
912 operator) is unsuitable.</p>
914 <div class="paragraph">
915 <p>Let’s write a <code>common_type</code> specialization for two <code>std::tuple</code> arguments. For that, we need a metafunction that
916 applies <code>std::common_type</code> to each pair of elements and gathers the results into a tuple:</p>
918 <div class="listingblock">
919 <div class="content">
920 <pre class="highlight"><code>template<class... T> using common_type_t =
921 typename std::common_type<T...>::type; // standard in C++14
923 template<class Tp1, class Tp2> using common_tuple =
924 mp_transform<common_type_t, Tp1, Tp2>;</code></pre>
927 <div class="paragraph">
928 <p>then specialize <code>common_type</code> to use it:</p>
930 <div class="listingblock">
931 <div class="content">
932 <pre class="highlight"><code>namespace std
935 template<class... T1, class... T2>
936 struct common_type<std::tuple<T1...>, std::tuple<T2...>>:
937 mp_defer<common_tuple, std::tuple<T1...>, std::tuple<T2...>>
941 } // std</code></pre>
944 <div class="paragraph">
945 <p>(There is no need to specialize <code>std::common_type</code> for more than two arguments - it takes care of synthesizing the appropriate semantics from
946 the binary case.)</p>
948 <div class="paragraph">
949 <p>The subtlety here is the use of <code>mp_defer</code>. We could have defined a nested <code>type</code> to <code>common_tuple<std::tuple<T1…​>, std::tuple<T2…​>></code>,
950 and it would still have worked in all valid cases. By letting <code>mp_defer</code> define <code>type</code>, though, we make our specialization <em>SFINAE-friendly</em>.</p>
952 <div class="paragraph">
953 <p>That is, when our <code>common_tuple</code> causes a substitution failure instead of a hard error, <code>mp_defer</code> will not define a nested <code>type</code>,
954 and <code>common_type_t</code>, which is defined as <code>typename common_type<…​>::type</code>, will also cause a substitution failure.</p>
956 <div class="paragraph">
957 <p>As another example, consider the hypothetical type <code>expected<T, E…​></code> that represents either a successful return with a value of <code>T</code>,
958 or an unsuccessful return with an error code of some type in the list <code>E…​</code>. The common type of <code>expected<T1, E1, E2, E3></code> and
959 <code>expected<T2, E1, E4, E5></code> is <code>expected<common_type_t<T1, T2>, E1, E2, E3, E4, E5></code>. That is, the possible return values are
960 combined into their common type, and we take the union of the set of error types.</p>
962 <div class="paragraph">
965 <div class="listingblock">
966 <div class="content">
967 <pre class="highlight"><code>template<class T1, class E1, class T2, class E2> using common_expected =
968 mp_rename<mp_push_front<mp_unique<mp_append<E1, E2>>, common_type_t<T1, T2>>,
974 template<class T1, class... E1, class T2, class... E2>
975 struct common_type<expected<T1, E1...>, expected<T2, E2...>>:
976 mp_defer<common_expected, T1, mp_list<E1...>, T2, mp_list<E2...>>
980 } // std</code></pre>
983 <div class="paragraph">
984 <p>Here we’ve taken a different tack; instead of passing the <code>expected</code> types to <code>common_expected</code>, we’re passing the <code>T</code> types and lists of
985 the <code>E</code> types. This makes our job easier. <code>mp_unique<mp_append<E1, E2>></code> gives us the concatenation of <code>E1</code> and <code>E2</code> with the duplicates
986 removed; we then add <code>common_type_t<T1, T2></code> to the front via <code>mp_push_front</code>; and finally, we <code>mp_rename</code> the resultant <code>mp_list</code>
987 to <code>expected</code>.</p>
991 <h3 id="fixing_tuple_cat">Fixing tuple_cat</h3>
992 <div class="paragraph">
993 <p>The article <a href="http://pdimov.com/cpp2/simple_cxx11_metaprogramming.html#">Simple C++11 metaprogramming</a> builds an
994 implementation of the standard function <code>tuple_cat</code>, with the end result given below:</p>
996 <div class="listingblock">
997 <div class="content">
998 <pre class="highlight"><code>template<class L> using F = mp_iota<mp_size<L>>;
1000 template<class R, class...Is, class... Ks, class Tp>
1001 R tuple_cat_( mp_list<Is...>, mp_list<Ks...>, Tp tp )
1003 return R{ std::get<Ks::value>(std::get<Is::value>(tp))... };
1006 template<class... Tp,
1007 class R = mp_append<std::tuple<>, typename std::remove_reference<Tp>::type...>>
1008 R tuple_cat( Tp &&... tp )
1010 std::size_t const N = sizeof...(Tp);
1014 using list1 = mp_list<
1015 mp_rename<typename std::remove_reference<Tp>::type, mp_list>...>;
1017 using list2 = mp_iota_c<N>;
1019 using list3 = mp_transform<mp_fill, list1, list2>;
1021 using inner = mp_apply<mp_append, list3>;
1025 using list4 = mp_transform<F, list1>;
1027 using outer = mp_apply<mp_append, list4>;
1031 return tuple_cat_<R>( inner(), outer(),
1032 std::forward_as_tuple( std::forward<Tp>(tp)... ) );
1036 <div class="paragraph">
1037 <p>This function, however, is not entirely correct, in that it doesn’t handle some cases properly. For example,
1038 trying to concatenate tuples containing move-only elements such as <code>unique_ptr</code> fails:</p>
1040 <div class="listingblock">
1041 <div class="content">
1042 <pre class="highlight"><code>std::tuple<std::unique_ptr<int>> t1;
1043 std::tuple<std::unique_ptr<float>> t2;
1045 auto result = ::tuple_cat( std::move( t1 ), std::move( t2 ) );</code></pre>
1048 <div class="paragraph">
1049 <p>Trying to concatenate <code>const</code> tuples fails:</p>
1051 <div class="listingblock">
1052 <div class="content">
1053 <pre class="highlight"><code>std::tuple<int> const t1;
1054 std::tuple<float> const t2;
1056 auto result = ::tuple_cat( t1, t2 );</code></pre>
1059 <div class="paragraph">
1060 <p>And finally, the standard <code>tuple_cat</code> is specified to work on arbitrary tuple-like types (that is, all types
1061 that support <code>tuple_size</code>, <code>tuple_element</code>, and <code>get</code>), while our implementation only works with <code>tuple</code> and
1062 <code>pair</code>. <code>std::array</code>, for example, fails:</p>
1064 <div class="listingblock">
1065 <div class="content">
1066 <pre class="highlight"><code>std::array<int, 2> t1{ 1, 2 };
1067 std::array<float, 3> t2{ 3.0f, 4.0f, 5.0f };
1069 auto result = ::tuple_cat( t1, t2 );</code></pre>
1072 <div class="paragraph">
1073 <p>Let’s fix these one by one. Support for move-only types is easy, if one knows where to look. The problem is
1074 that <code>Tp</code> that we’re passing to the helper <code>tuple_cat_</code> is (correctly) <code>tuple<unique_ptr<int>&&, unique_ptr<float>&&></code>,
1075 but <code>std::get<0>(tp)</code> still returns <code>unique_ptr<int>&</code>, because <code>tp</code> is an lvalue. This behavior is a bit
1076 surprising, but is intended to prevent inadvertent double moves.</p>
1078 <div class="paragraph">
1079 <p>Long story short, we need <code>std::move(tp)</code> in <code>tuple_cat_</code> to make <code>tp</code> an rvalue:</p>
1081 <div class="literalblock">
1082 <div class="content">
1083 <pre>template<class R, class...Is, class... Ks, class Tp>
1084 R tuple_cat_( mp_list<Is...>, mp_list<Ks...>, Tp tp )
1086 return R{ std::get<Ks::value>(std::get<Is::value>(std::move(tp)))... };
1090 <div class="paragraph">
1091 <p>Next, <code>const</code>-qualified tuples. The issue here is that we’re stripping references from the input tuples, but not
1092 <code>const</code>. As a result, we’re trying to manipulate types such as <code>tuple<int> const</code> with Mp11 algorithms, and these
1093 types do not fit the list concept. We just need to strip qualifiers as well, by defining the useful <code>remove_cv_ref</code>
1094 primitive that is inexplicably missing from the standard library:</p>
1096 <div class="literalblock">
1097 <div class="content">
1098 <pre>template<class T> using remove_cv_ref = typename std::remove_cv<
1099 typename std::remove_reference<T>::type>::type;</pre>
1102 <div class="paragraph">
1103 <p>and then by using <code>remove_cv_ref<Tp></code> in place of <code>typename std::remove_reference<Tp>::type</code>:</p>
1105 <div class="listingblock">
1106 <div class="content">
1107 <pre class="highlight"><code>template<class... Tp,
1108 class R = mp_append<std::tuple<>, remove_cv_ref<Tp>...>>
1109 R tuple_cat( Tp &&... tp )
1111 std::size_t const N = sizeof...(Tp);
1115 using list1 = mp_list<mp_rename<remove_cv_ref<Tp>, mp_list>...>;
1120 <div class="paragraph">
1121 <p>Finally, tuple-like types. We’ve so far exploited the fact that <code>std::pair</code> and <code>std::tuple</code> are valid Mp11 lists,
1122 but in general, arbitrary tuple-like types aren’t, so we need to convert them into such. For that, we’ll need to
1123 define a metafunction <code>from_tuple_like</code> that will take an arbitrary tuple-like type and will return, in our case,
1124 the corresponding <code>mp_list</code>.</p>
1126 <div class="paragraph">
1127 <p>Technically, a more principled approach would’ve been to return <code>std::tuple</code>, but here <code>mp_list</code> will prove more
1130 <div class="paragraph">
1131 <p>What we need is, given a tuple-like type <code>Tp</code>, to obtain <code>mp_list<std::tuple_element<0, Tp>::type, std::tuple_element<1, Tp>::type,
1132 …​, std::tuple_element<N-1, Tp>::type></code>, where <code>N</code> is <code>tuple_size<Tp>::value</code>. Here’s one way to do it:</p>
1134 <div class="listingblock">
1135 <div class="content">
1136 <pre class="highlight"><code>template<class T, class I> using tuple_element =
1137 typename std::tuple_element<I::value, T>::type;
1139 template<class T> using from_tuple_like =
1140 mp_product<tuple_element, mp_list<T>, mp_iota<std::tuple_size<T>>>;</code></pre>
1143 <div class="paragraph">
1144 <p>(<code>mp_iota<N></code> is an algorithm that returns an <code>mp_list</code> with elements <code>mp_size_t<0></code>, <code>mp_size_t<1></code>, …​, <code>mp_size_t<N-1></code>.)</p>
1146 <div class="paragraph">
1147 <p>Remember that <code>mp_product<F, L1, L2></code> performs the equivalent of two nested loops over the elements of <code>L1</code> and <code>L2</code>,
1148 applying <code>F</code> to the two variables and gathering the result. In our case <code>L1</code> consists of the single element <code>T</code>, so
1149 only the second loop (over <code>mp_iota<N></code>, where <code>N</code> is <code>tuple_size<T></code>), remains, and we get a list of the same type
1150 as <code>L1</code> (an <code>mp_list</code>) with contents <code>tuple_element<T, mp_size_t<0>></code>, <code>tuple_element<T, mp_size_t<1>></code>, …​,
1151 <code>tuple_element<T, mp_size_t<N-1>></code>.</p>
1153 <div class="paragraph">
1154 <p>For completeness’s sake, here’s another, more traditional way to achieve the same result:</p>
1156 <div class="literalblock">
1157 <div class="content">
1158 <pre>template<class T> using from_tuple_like =
1159 mp_transform_q<mp_bind_front<tuple_element, T>, mp_iota<std::tuple_size<T>>>;</pre>
1162 <div class="paragraph">
1163 <p>With all these fixes applied, our fully operational <code>tuple_cat</code> now looks like this:</p>
1165 <div class="listingblock">
1166 <div class="content">
1167 <pre class="highlight"><code>template<class L> using F = mp_iota<mp_size<L>>;
1169 template<class R, class...Is, class... Ks, class Tp>
1170 R tuple_cat_( mp_list<Is...>, mp_list<Ks...>, Tp tp )
1172 return R{ std::get<Ks::value>(std::get<Is::value>(std::move(tp)))... };
1175 template<class T> using remove_cv_ref = typename std::remove_cv<
1176 typename std::remove_reference<T>::type>::type;
1178 template<class T, class I> using tuple_element =
1179 typename std::tuple_element<I::value, T>::type;
1181 template<class T> using from_tuple_like =
1182 mp_product<tuple_element, mp_list<T>, mp_iota<std::tuple_size<T>>>;
1184 template<class... Tp,
1185 class R = mp_append<std::tuple<>, from_tuple_like<remove_cv_ref<Tp>>...>>
1186 R tuple_cat( Tp &&... tp )
1188 std::size_t const N = sizeof...(Tp);
1192 using list1 = mp_list<from_tuple_like<remove_cv_ref<Tp>>...>;
1193 using list2 = mp_iota_c<N>;
1195 using list3 = mp_transform<mp_fill, list1, list2>;
1197 using inner = mp_apply<mp_append, list3>;
1201 using list4 = mp_transform<F, list1>;
1203 using outer = mp_apply<mp_append, list4>;
1207 return tuple_cat_<R>( inner(), outer(),
1208 std::forward_as_tuple( std::forward<Tp>(tp)... ) );
1214 <h3 id="computing_return_types">Computing Return Types</h3>
1215 <div class="paragraph">
1216 <p>C++17 has a standard variant type, called <code>std::variant</code>. It also defines a function template
1217 <code>std::visit</code> that can be used to apply a function to the contained value of one or more variants.
1218 So for instance, if the variant <code>v1</code> contains <code>1</code>, and the variant <code>v2</code> contains <code>2.0f</code>,
1219 <code>std::visit(f, v1, v2)</code> will call <code>f(1, 2.0f)</code>.</p>
1221 <div class="paragraph">
1222 <p>However, <code>std::visit</code> has one limitation: it cannot return a result unless all
1223 possible applications of the function have the same return type. If, for instance, <code>v1</code> and <code>v2</code>
1224 are both of type <code>std::variant<short, int, float></code>,</p>
1226 <div class="literalblock">
1227 <div class="content">
1228 <pre>std::visit( []( auto const& x, auto const& y ){ return x + y; }, v1, v2 );</pre>
1231 <div class="paragraph">
1232 <p>will fail to compile because the result of <code>x + y</code> can be either <code>int</code> or <code>float</code> depending on
1233 what <code>v1</code> and <code>v2</code> hold.</p>
1235 <div class="paragraph">
1236 <p>A type that can hold either <code>int</code> or <code>float</code> already exists, called, surprisingly enough, <code>std::variant<int, float></code>.
1237 Let’s write our own function template <code>rvisit</code> that is the same as <code>visit</code> but returns a <code>variant</code>:</p>
1239 <div class="listingblock">
1240 <div class="content">
1241 <pre class="highlight"><code>template<class F, class... V> auto rvisit( F&& f, V&&... v )
1245 return std::visit( [&]( auto&&... x )
1246 { return R( std::forward<F>(f)( std::forward<decltype(x)>(x)... ) ); },
1247 std::forward<V>( v )... );
1251 <div class="paragraph">
1252 <p>What this does is basically calls <code>std::visit</code> to do the work, but instead of passing it <code>f</code>, we pass a lambda that does the same as <code>f</code> except
1253 it converts the result to a common type <code>R</code>. <code>R</code> is supposed to be <code>std::variant<…​></code> where the ellipsis denotes the return types of
1254 calling <code>f</code> with all possible combinations of variant values.</p>
1256 <div class="paragraph">
1257 <p>We’ll first define a helper quoted metafunction <code>Qret<F></code> that returns the result of the application of <code>F</code> to arguments of type <code>T…​</code>:</p>
1259 <div class="literalblock">
1260 <div class="content">
1261 <pre>template<class F> struct Qret
1263 template<class... T> using fn =
1264 decltype( std::declval<F>()( std::declval<T>()... ) );
1268 <div class="paragraph">
1269 <p>(Unfortunately, we can’t just define this metafunction inside <code>rvisit</code>; the language prohibits defining template aliases inside functions.)</p>
1271 <div class="paragraph">
1272 <p>With <code>Qret</code> in hand, a <code>variant</code> of the possible return types is just a matter of applying it over the possible combinations of the variant values:</p>
1274 <div class="literalblock">
1275 <div class="content">
1276 <pre>using R = mp_product_q<Qret<F>, std::remove_reference_t<V>...>;</pre>
1279 <div class="paragraph">
1280 <p>Why does this work? <code>mp_product<F, L1<T1…​>, L2<T2…​>, …​, Ln<Tn…​>></code> returns <code>L1<F<U1, U2, …​, Un>, …​></code>, where <code>Ui</code> traverse all
1281 possible combinations of list values. Since in our case all <code>Li</code> are <code>std::variant</code>, the result will also be <code>std::variant</code>. (<code>mp_product_q</code> is
1282 the same as <code>mp_product</code>, but for quoted metafunctions such as our <code>Qret<F></code>.)</p>
1284 <div class="paragraph">
1285 <p>One more step remains. Suppose that, as above, we’re passing two variants of type <code>std::variant<short, int, float></code> and <code>F</code> is
1286 <code>[]( auto const& x, auto const& y ){ return x + y; }</code>. This will generate <code>R</code> of length 9, one per each combination, but many of those
1287 elements will be the same, either <code>int</code> or <code>float</code>, and we need to filter out the duplicates. So, we pass the result to <code>mp_unique</code>:</p>
1289 <div class="literalblock">
1290 <div class="content">
1291 <pre>using R = mp_unique<mp_product_q<Qret<F>, std::remove_reference_t<V>...>>;</pre>
1294 <div class="paragraph">
1295 <p>and we’re done:</p>
1297 <div class="listingblock">
1298 <div class="content">
1299 <pre class="highlight"><code>#include <boost/mp11.hpp>
1300 #include <boost/core/demangle.hpp>
1301 #include <variant>
1302 #include <type_traits>
1303 #include <typeinfo>
1304 #include <iostream>
1306 using namespace boost::mp11;
1308 template<class F> struct Qret
1310 template<class... T> using fn =
1311 decltype( std::declval<F>()( std::declval<T>()... ) );
1314 template<class F, class... V> auto rvisit( F&& f, V&&... v )
1316 using R = mp_unique<mp_product_q<Qret<F>, std::remove_reference_t<V>...>>;
1318 return std::visit( [&]( auto&&... x )
1319 { return R( std::forward<F>(f)( std::forward<decltype(x)>(x)... ) ); },
1320 std::forward<V>( v )... );
1323 template<class T> std::string name()
1325 return boost::core::demangle( typeid(T).name() );
1328 template<class V> void print_variant( char const * n, V const& v )
1330 std::cout << "(" << name<decltype(v)>() << ")" << n << ": ";
1332 std::visit( []( auto const& x )
1333 { std::cout << "(" << name<decltype(x)>() << ")" << x << std::endl; }, v );
1338 std::variant<char, int, float> v1( 1 );
1340 print_variant( "v1", v1 );
1342 std::variant<short, int, double> v2( 3.14 );
1344 print_variant( "v2", v2 );
1346 auto v3 = rvisit( []( auto const& x, auto const& y ){ return x + y; }, v1, v2 );
1348 print_variant( "v3", v3 );
1356 <h2 id="changelog">Revision History</h2>
1357 <div class="sectionbody">
1359 <h3 id="changes_in_1_70_0">Changes in 1.70.0</h3>
1363 <p>Renamed <code>mp_invoke</code> to <code>mp_invoke_q</code></p>
1366 <p>Added <code>mp_similar</code></p>
1369 <p>Added <code>mp_set_union</code>, <code>mp_set_intersection</code>, <code>mp_set_difference</code></p>
1372 <p>Added <code>mp_not_fn</code></p>
1375 <p>Added <code>mp_transform_first</code>, <code>mp_transform_second</code>, <code>mp_transform_third</code></p>
1378 <p>Added <code>mp_filter</code></p>
1381 <p>Added <code>mp_eval_if_not</code>, <code>mp_eval_or</code>, <code>mp_valid_q</code></p>
1384 <p>Added <code>mp_back</code>, <code>mp_pop_back</code></p>
1387 <p>Added <code>BOOST_MP11_VERSION</code></p>
1393 <h3 id="changes_in_1_69_0">Changes in 1.69.0</h3>
1397 <p>Removed dependency on Boost.Config; Mp11 is now standalone</p>
1400 <p>Improved code generation for <code>mp_with_index</code></p>
1403 <p>Added <code>mp_starts_with</code> (contributed by Glen Fernandes)</p>
1406 <p>Added CMake support</p>
1414 <h2 id="reference">Reference</h2>
1415 <div class="sectionbody">
1416 <div class="paragraph">
1417 <p>The contents of the library are in namespace <code>boost::mp11</code>.</p>
1420 <h3 id="integral">Integral Constants, <boost/mp11/integral.hpp></h3>
1421 <div class="paragraph">
1422 <p>For an Mp11 integral constant type <code>T</code>, <code>T::value</code> is an integral constant in the C++ sense.</p>
1425 <h4 id="mp_boolb">mp_bool<B></h4>
1426 <div class="literalblock">
1427 <div class="content">
1428 <pre>template<bool B> using mp_bool = std::integral_constant<bool, B>;</pre>
1431 <div class="paragraph">
1432 <p>Same as <code>std::bool_constant</code> in C++17.</p>
1436 <h4 id="mp_true">mp_true</h4>
1437 <div class="literalblock">
1438 <div class="content">
1439 <pre>using mp_true = mp_bool<true>;</pre>
1442 <div class="paragraph">
1443 <p>Same as <code>std::true_type</code>.</p>
1447 <h4 id="mp_false">mp_false</h4>
1448 <div class="literalblock">
1449 <div class="content">
1450 <pre>using mp_false = mp_bool<false>;</pre>
1453 <div class="paragraph">
1454 <p>Same as <code>std::false_type</code>.</p>
1458 <h4 id="mp_to_boolt">mp_to_bool<T></h4>
1459 <div class="literalblock">
1460 <div class="content">
1461 <pre>template<class T> using mp_to_bool = mp_bool<static_cast<bool>(T::value)>;</pre>
1466 <h4 id="mp_nott">mp_not<T></h4>
1467 <div class="literalblock">
1468 <div class="content">
1469 <pre>template<class T> using mp_not = mp_bool< !T::value >;</pre>
1474 <h4 id="mp_inti">mp_int<I></h4>
1475 <div class="literalblock">
1476 <div class="content">
1477 <pre>template<int I> using mp_int = std::integral_constant<int, I>;</pre>
1482 <h4 id="mp_size_tn">mp_size_t<N></h4>
1483 <div class="literalblock">
1484 <div class="content">
1485 <pre>template<std::size_t N> using mp_size_t = std::integral_constant<std::size_t, N>;</pre>
1491 <h3 id="list">List Operations, <boost/mp11/list.hpp></h3>
1493 <h4 id="mp_listt">mp_list<T…​></h4>
1494 <div class="literalblock">
1495 <div class="content">
1496 <pre>template<class... T> struct mp_list {};</pre>
1499 <div class="paragraph">
1500 <p><code>mp_list</code> is the standard list type of Mp11, although the library is not restricted to it and can operate on arbitrary class templates
1501 such as <code>std::tuple</code> or <code>std::variant</code>. Even <code>std::pair</code> can be used if the transformation does not alter the number of the elements in
1506 <h4 id="mp_list_ct_i">mp_list_c<T, I…​></h4>
1507 <div class="literalblock">
1508 <div class="content">
1509 <pre>template<class T, T... I> using mp_list_c =
1510 mp_list<std::integral_constant<T, I>...>;</pre>
1513 <div class="paragraph">
1514 <p><code>mp_list_c</code> produces an <code>mp_list</code> of the <code>std::integral_constant</code> types corresponding to its integer template arguments.</p>
1516 <div class="listingblock">
1517 <div class="title">Code Example 1. Using mp_list_c</div>
1518 <div class="content">
1519 <pre class="highlight"><code>using L1 = mp_list_c<int, 2, 3>; // mp_list<mp_int<2>, mp_int<3>></code></pre>
1524 <h4 id="mp_is_listl">mp_is_list<L></h4>
1525 <div class="literalblock">
1526 <div class="content">
1527 <pre>template<class L> using mp_is_list = /*...*/;</pre>
1530 <div class="paragraph">
1531 <p><code>mp_is_list<L></code> is <code>mp_true</code> if <code>L</code> is a list (an instantiation of a class template whose template parameters are types), <code>mp_false</code> otherwise.</p>
1535 <h4 id="mp_sizel">mp_size<L></h4>
1536 <div class="literalblock">
1537 <div class="content">
1538 <pre>template<class L> using mp_size = /*...*/;</pre>
1541 <div class="paragraph">
1542 <p><code>mp_size<L></code> returns the number of elements in the list <code>L</code>, as a <code>mp_size_t</code>. In other words, <code>mp_size<L<T…​>></code> is an alias for
1543 <code>mp_size_t<sizeof…​(T)></code>.</p>
1545 <div class="listingblock">
1546 <div class="title">Code Example 2. Using mp_size with mp_list</div>
1547 <div class="content">
1548 <pre class="highlight"><code>using L1 = mp_list<>;
1549 using R1 = mp_size<L1>; // mp_size_t<0></code></pre>
1552 <div class="listingblock">
1553 <div class="title">Code Example 3. Using mp_size with std::pair</div>
1554 <div class="content">
1555 <pre class="highlight"><code>using L2 = std::pair<int, int>;
1556 using R2 = mp_size<L2>; // mp_size_t<2></code></pre>
1559 <div class="listingblock">
1560 <div class="title">Code Example 4. Using mp_size with std::tuple</div>
1561 <div class="content">
1562 <pre class="highlight"><code>using L3 = std::tuple<float>;
1563 using R3 = mp_size<L3>; // mp_size_t<1></code></pre>
1568 <h4 id="mp_emptyl">mp_empty<L></h4>
1569 <div class="literalblock">
1570 <div class="content">
1571 <pre>template<class L> using mp_empty = mp_bool<mp_size<L>::value == 0>;</pre>
1574 <div class="paragraph">
1575 <p><code>mp_empty<L></code> is an alias for <code>mp_true</code> if the list <code>L</code> is empty, for <code>mp_false</code> otherwise.</p>
1577 <div class="listingblock">
1578 <div class="title">Code Example 5. Using mp_empty with std::tuple</div>
1579 <div class="content">
1580 <pre class="highlight"><code>using L1 = std::tuple<float>;
1581 using R1 = mp_empty<L1>; // mp_false
1583 using L2 = std::tuple<>;
1584 using R2 = mp_empty<L2>; // mp_true</code></pre>
1589 <h4 id="mp_assignl1_l2">mp_assign<L1, L2></h4>
1590 <div class="literalblock">
1591 <div class="content">
1592 <pre>template<class L1, class L2> using mp_assign = /*...*/;</pre>
1595 <div class="paragraph">
1596 <p><code>mp_assign<L1<T1…​>, L2<T2…​>></code> is an alias for <code>L1<T2…​></code>. That is, it replaces the elements of <code>L1</code> with those of <code>L2</code>.</p>
1598 <div class="listingblock">
1599 <div class="title">Code Example 6. Using mp_assign with mp_list and std::tuple</div>
1600 <div class="content">
1601 <pre class="highlight"><code>using L1 = std::tuple<long>;
1602 using L2 = mp_list<int, float>;
1604 using R1 = mp_assign<L1, L2>; // std::tuple<int, float></code></pre>
1607 <div class="listingblock">
1608 <div class="title">Code Example 7. Using mp_assign with mp_list and std::pair</div>
1609 <div class="content">
1610 <pre class="highlight"><code>using L1 = std::pair<long, char>;
1611 using L2 = mp_list<int, float>;
1613 using R1 = mp_assign<L1, L2>; // std::pair<int, float></code></pre>
1618 <h4 id="mp_clearl">mp_clear<L></h4>
1619 <div class="literalblock">
1620 <div class="content">
1621 <pre>template<class L> using mp_clear = mp_assign<L, mp_list<>>;</pre>
1624 <div class="paragraph">
1625 <p><code>mp_clear<L<T…​>></code> is an alias for <code>L<></code>, that is, it removes the elements of <code>L</code>.</p>
1627 <div class="listingblock">
1628 <div class="title">Code Example 8. Using mp_clear with std::tuple</div>
1629 <div class="content">
1630 <pre class="highlight"><code>using L1 = std::tuple<int, float>;
1631 using R1 = mp_clear<L1>; // std::tuple<></code></pre>
1636 <h4 id="mp_frontl">mp_front<L></h4>
1637 <div class="literalblock">
1638 <div class="content">
1639 <pre>template<class L> using mp_front = /*...*/;</pre>
1642 <div class="paragraph">
1643 <p><code>mp_front<L></code> is the first element of the list <code>L</code>. That is, <code>mp_front<L<T1, T…​>></code> is an alias for <code>T1</code>.</p>
1645 <div class="listingblock">
1646 <div class="title">Code Example 9. Using mp_front with std::pair</div>
1647 <div class="content">
1648 <pre class="highlight"><code>using L1 = std::pair<int, float>;
1649 using R1 = mp_front<L1>; // int</code></pre>
1652 <div class="listingblock">
1653 <div class="title">Code Example 10. Using mp_front with std::tuple</div>
1654 <div class="content">
1655 <pre class="highlight"><code>using L2 = std::tuple<float, double, long double>;
1656 using R2 = mp_front<L2>; // float</code></pre>
1659 <div class="listingblock">
1660 <div class="title">Code Example 11. Using mp_front with mp_list</div>
1661 <div class="content">
1662 <pre class="highlight"><code>using L3 = mp_list<char[1], char[2], char[3], char[4]>;
1663 using R3 = mp_front<L3>; // char[1]</code></pre>
1668 <h4 id="mp_pop_frontl">mp_pop_front<L></h4>
1669 <div class="literalblock">
1670 <div class="content">
1671 <pre>template<class L> using mp_pop_front = /*...*/;</pre>
1674 <div class="paragraph">
1675 <p><code>mp_pop_front<L></code> removes the first element of the list <code>L</code>. That is, <code>mp_pop_front<L<T1, T…​>></code> is an alias for <code>L<T…​></code>.</p>
1677 <div class="listingblock">
1678 <div class="title">Code Example 12. Using mp_pop_front with std::tuple</div>
1679 <div class="content">
1680 <pre class="highlight"><code>using L1 = std::tuple<float, double, long double>;
1681 using R1 = mp_pop_front<L1>; // std::tuple<double, long double></code></pre>
1684 <div class="listingblock">
1685 <div class="title">Code Example 13. Using mp_pop_front with mp_list</div>
1686 <div class="content">
1687 <pre class="highlight"><code>using L2 = mp_list<void>;
1688 using R2 = mp_pop_front<L2>; // mp_list<></code></pre>
1693 <h4 id="mp_firstl">mp_first<L></h4>
1694 <div class="literalblock">
1695 <div class="content">
1696 <pre>template<class L> using mp_first = mp_front<L>;</pre>
1699 <div class="paragraph">
1700 <p><code>mp_first</code> is another name for <code>mp_front</code>.</p>
1704 <h4 id="mp_restl">mp_rest<L></h4>
1705 <div class="literalblock">
1706 <div class="content">
1707 <pre>template<class L> using mp_rest = mp_pop_front<L>;</pre>
1710 <div class="paragraph">
1711 <p><code>mp_rest</code> is another name for <code>mp_pop_front</code>.</p>
1715 <h4 id="mp_secondl">mp_second<L></h4>
1716 <div class="literalblock">
1717 <div class="content">
1718 <pre>template<class L> using mp_second = /*...*/;</pre>
1721 <div class="paragraph">
1722 <p><code>mp_second<L></code> is the second element of the list <code>L</code>. That is, <code>mp_second<L<T1, T2, T…​>></code> is an alias for <code>T2</code>.</p>
1724 <div class="listingblock">
1725 <div class="title">Code Example 14. Using mp_second with std::pair</div>
1726 <div class="content">
1727 <pre class="highlight"><code>using L1 = std::pair<int, float>;
1728 using R1 = mp_second<L1>; // float</code></pre>
1731 <div class="listingblock">
1732 <div class="title">Code Example 15. Using mp_second with std::tuple</div>
1733 <div class="content">
1734 <pre class="highlight"><code>using L2 = std::tuple<float, double, long double>;
1735 using R2 = mp_second<L2>; // double</code></pre>
1738 <div class="listingblock">
1739 <div class="title">Code Example 16. Using mp_second with mp_list</div>
1740 <div class="content">
1741 <pre class="highlight"><code>using L3 = mp_list<char[1], char[2], char[3], char[4]>;
1742 using R3 = mp_second<L3>; // char[2]</code></pre>
1747 <h4 id="mp_thirdl">mp_third<L></h4>
1748 <div class="literalblock">
1749 <div class="content">
1750 <pre>template<class L> using mp_third = /*...*/;</pre>
1753 <div class="paragraph">
1754 <p><code>mp_third<L></code> is the third element of the list <code>L</code>. That is, <code>mp_third<L<T1, T2, T3, T…​>></code> is an alias for <code>T3</code>.</p>
1756 <div class="listingblock">
1757 <div class="title">Code Example 17. Using mp_third with std::tuple</div>
1758 <div class="content">
1759 <pre class="highlight"><code>using L1 = std::tuple<float, double, long double>;
1760 using R1 = mp_third<L1>; // long double</code></pre>
1763 <div class="listingblock">
1764 <div class="title">Code Example 18. Using mp_third with mp_list</div>
1765 <div class="content">
1766 <pre class="highlight"><code>using L2 = mp_list<char[1], char[2], char[3], char[4]>;
1767 using R2 = mp_third<L2>; // char[3]</code></pre>
1772 <h4 id="mp_push_frontl_t">mp_push_front<L, T…​></h4>
1773 <div class="literalblock">
1774 <div class="content">
1775 <pre>template<class L, class... T> using mp_push_front = /*...*/;</pre>
1778 <div class="paragraph">
1779 <p><code>mp_push_front<L, T…​></code> inserts the elements <code>T…​</code> at the front of the list <code>L</code>. That is, <code>mp_push_front<L<U…​>, T…​></code>
1780 is an alias for <code>L<T…​, U…​></code>.</p>
1782 <div class="listingblock">
1783 <div class="title">Code Example 19. Using mp_push_front with std::tuple</div>
1784 <div class="content">
1785 <pre class="highlight"><code>using L1 = std::tuple<double, long double>;
1786 using R1 = mp_push_front<L1, float>; // std::tuple<float, double, long double></code></pre>
1789 <div class="listingblock">
1790 <div class="title">Code Example 20. Using mp_push_front with mp_list</div>
1791 <div class="content">
1792 <pre class="highlight"><code>using L2 = mp_list<void>;
1793 using R2 = mp_push_front<L2, char[1], char[2]>; // mp_list<char[1], char[2], void></code></pre>
1798 <h4 id="mp_push_backl_t">mp_push_back<L, T…​></h4>
1799 <div class="literalblock">
1800 <div class="content">
1801 <pre>template<class L, class... T> using mp_push_back = /*...*/;</pre>
1804 <div class="paragraph">
1805 <p><code>mp_push_back<L, T…​></code> inserts the elements <code>T…​</code> at the back of the list <code>L</code>. That is, <code>mp_push_back<L<U…​>, T…​></code>
1806 is an alias for <code>L<U…​, T…​></code>.</p>
1808 <div class="listingblock">
1809 <div class="title">Code Example 21. Using mp_push_back with std::tuple</div>
1810 <div class="content">
1811 <pre class="highlight"><code>using L1 = std::tuple<double, long double>;
1812 using R1 = mp_push_back<L1, float>; // std::tuple<double, long double, float></code></pre>
1815 <div class="listingblock">
1816 <div class="title">Code Example 22. Using mp_push_back with mp_list</div>
1817 <div class="content">
1818 <pre class="highlight"><code>using L2 = mp_list<void>;
1819 using R2 = mp_push_back<L2, char[1], char[2]>; // mp_list<void, char[1], char[2]></code></pre>
1824 <h4 id="mp_renamel_y">mp_rename<L, Y></h4>
1825 <div class="literalblock">
1826 <div class="content">
1827 <pre>template<class L, template<class...> class Y> using mp_rename = /*...*/;</pre>
1830 <div class="paragraph">
1831 <p><code>mp_rename<L, Y></code> changes the type of the list <code>L</code> to <code>Y</code>. That is, <code>mp_rename<L<T…​>, Y></code> is an alias for <code>Y<T…​></code>.</p>
1833 <div class="listingblock">
1834 <div class="title">Code Example 23. Using mp_rename to rename std::pair to std::tuple</div>
1835 <div class="content">
1836 <pre class="highlight"><code>using L1 = std::pair<double, long double>;
1837 using R1 = mp_rename<L1, std::tuple>; // std::tuple<double, long double></code></pre>
1840 <div class="listingblock">
1841 <div class="title">Code Example 24. Using mp_rename to rename std::tuple to mp_list</div>
1842 <div class="content">
1843 <pre class="highlight"><code>using L2 = std::tuple<void>;
1844 using R2 = mp_rename<L2, mp_list>; // mp_list<void></code></pre>
1849 <h4 id="mp_applyf_l">mp_apply<F, L></h4>
1850 <div class="literalblock">
1851 <div class="content">
1852 <pre>template<template<class...> class F, class L> using mp_apply = mp_rename<L, F>;</pre>
1855 <div class="paragraph">
1856 <p><code>mp_apply<F, L></code> applies the metafunction <code>F</code> to the contents of the list <code>L</code>, that is, <code>mp_apply<F, L<T…​>></code> is an alias for <code>F<T…​></code>.
1857 (<code>mp_apply</code> is the same as <code>mp_rename</code> with the arguments reversed.)</p>
1859 <div class="listingblock">
1860 <div class="title">Code Example 25. Using mp_apply with std::pair</div>
1861 <div class="content">
1862 <pre class="highlight"><code>using L1 = std::pair<double, long double>;
1863 using R1 = mp_apply<std::is_same, L1>; // std::is_same<double, long double></code></pre>
1868 <h4 id="mp_apply_qq_l">mp_apply_q<Q, L></h4>
1869 <div class="literalblock">
1870 <div class="content">
1871 <pre>template<class Q, class L> using mp_apply_q = mp_apply<Q::template fn, L>;</pre>
1874 <div class="paragraph">
1875 <p>Same as <code>mp_apply</code>, but takes a quoted metafunction.</p>
1877 <div class="listingblock">
1878 <div class="title">Code Example 26. Using mp_apply_q with mp_bind_front</div>
1879 <div class="content">
1880 <pre class="highlight"><code>using L1 = std::tuple<double, long double>;
1881 using L2 = mp_list<int, long>;
1883 using R1 = mp_apply_q<mp_bind_front<mp_push_back, L1>, L2>;
1884 // R1 is std::tuple<double, long double, int, long></code></pre>
1889 <h4 id="mp_appendl">mp_append<L…​></h4>
1890 <div class="literalblock">
1891 <div class="content">
1892 <pre>template<class... L> using mp_append = /*...*/;</pre>
1895 <div class="paragraph">
1896 <p><code>mp_append<L…​></code> concatenates the lists in <code>L…​</code> into a single list that has the same type as the first list. <code>mp_append<></code>
1897 is an alias for <code>mp_list<></code>. <code>mp_append<L1<T1…​>, L2<T2…​>, …​, Ln<Tn…​>></code> is an alias for <code>L1<T1…​, T2…​, …​, Tn…​></code>.</p>
1899 <div class="listingblock">
1900 <div class="title">Code Example 27. Using mp_append with lists of various types</div>
1901 <div class="content">
1902 <pre class="highlight"><code>using L1 = std::tuple<double, long double>;
1903 using L2 = mp_list<int>;
1904 using L3 = std::pair<short, long>;
1905 using L4 = mp_list<>;
1907 using R1 = mp_append<L1, L2, L3, L4>;
1908 // std::tuple<double, long double, int, short, long></code></pre>
1913 <h4 id="mp_replace_frontl_t">mp_replace_front<L, T></h4>
1914 <div class="literalblock">
1915 <div class="content">
1916 <pre>template<class L, class T> using mp_replace_front = /*...*/;</pre>
1919 <div class="paragraph">
1920 <p><code>mp_replace_front<L, T></code> replaces the first element of the list <code>L</code> with <code>T</code>. That is, <code>mp_replace_front<L<U1, U…​>, T></code> is
1921 an alias for <code>L<T, U…​></code>.</p>
1923 <div class="listingblock">
1924 <div class="title">Code Example 28. Using mp_replace_front with std::pair</div>
1925 <div class="content">
1926 <pre class="highlight"><code>using L1 = std::pair<int, float>;
1927 using R1 = mp_replace_front<L1, void>; // std::pair<void, float></code></pre>
1930 <div class="listingblock">
1931 <div class="title">Code Example 29. Using mp_replace_front with std::tuple</div>
1932 <div class="content">
1933 <pre class="highlight"><code>using L2 = std::tuple<float, double, long double>;
1934 using R2 = mp_replace_front<L2, void>; // std::tuple<void, double, long double></code></pre>
1937 <div class="listingblock">
1938 <div class="title">Code Example 30. Using mp_replace_front with mp_list</div>
1939 <div class="content">
1940 <pre class="highlight"><code>using L3 = mp_list<char[1], char[2], char[3], char[4]>;
1941 using R3 = mp_replace_front<L3, void>; // mp_list<void, char[2], char[3], char[4]>;</code></pre>
1946 <h4 id="mp_replace_firstl_t">mp_replace_first<L, T></h4>
1947 <div class="literalblock">
1948 <div class="content">
1949 <pre>template<class L, class T> using mp_replace_first = mp_replace_front<L, T>;</pre>
1952 <div class="paragraph">
1953 <p><code>mp_replace_first</code> is another name for <code>mp_replace_front</code>.</p>
1957 <h4 id="mp_replace_secondl_t">mp_replace_second<L, T></h4>
1958 <div class="literalblock">
1959 <div class="content">
1960 <pre>template<class L, class T> using mp_replace_second = /*...*/;</pre>
1963 <div class="paragraph">
1964 <p><code>mp_replace_second<L, T></code> replaces the second element of the list <code>L</code> with <code>T</code>. That is, <code>mp_replace_second<L<U1, U2, U…​>, T></code>
1965 is an alias for <code>L<U1, T, U…​></code>.</p>
1967 <div class="listingblock">
1968 <div class="title">Code Example 31. Using mp_replace_second with std::pair</div>
1969 <div class="content">
1970 <pre class="highlight"><code>using L1 = std::pair<int, float>;
1971 using R1 = mp_replace_second<L1, void>; // std::pair<int, void></code></pre>
1974 <div class="listingblock">
1975 <div class="title">Code Example 32. Using mp_replace_second with std::tuple</div>
1976 <div class="content">
1977 <pre class="highlight"><code>using L2 = std::tuple<float, double, long double>;
1978 using R2 = mp_replace_second<L2, void>; // std::tuple<float, void, long double></code></pre>
1981 <div class="listingblock">
1982 <div class="title">Code Example 33. Using mp_replace_front with mp_list</div>
1983 <div class="content">
1984 <pre class="highlight"><code>using L3 = mp_list<char[1], char[2], char[3], char[4]>;
1985 using R3 = mp_replace_second<L3, void>; // mp_list<char[1], void, char[3], char[4]>;</code></pre>
1990 <h4 id="mp_replace_thirdl_t">mp_replace_third<L, T></h4>
1991 <div class="literalblock">
1992 <div class="content">
1993 <pre>template<class L, class T> using mp_replace_third = /*...*/;</pre>
1996 <div class="paragraph">
1997 <p><code>mp_replace_third<L, T></code> replaces the third element of the list <code>L</code> with <code>T</code>. That is, <code>mp_replace_third<L<U1, U2, U3, U…​>, T></code>
1998 is an alias for <code>L<U1, U2, T, U…​></code>.</p>
2000 <div class="listingblock">
2001 <div class="title">Code Example 34. Using mp_replace_third with std::tuple</div>
2002 <div class="content">
2003 <pre class="highlight"><code>using L1 = std::tuple<float, double, long double>;
2004 using R1 = mp_replace_third<L1, void>; // std::tuple<float, double, void></code></pre>
2007 <div class="listingblock">
2008 <div class="title">Code Example 35. Using mp_replace_third with mp_list</div>
2009 <div class="content">
2010 <pre class="highlight"><code>using L2 = mp_list<char[1], char[2], char[3], char[4]>;
2011 using R2 = mp_replace_third<L2, void>; // mp_list<char[1], char[2], void, char[4]>;</code></pre>
2016 <h4 id="mp_transform_frontl_f">mp_transform_front<L, F></h4>
2017 <div class="literalblock">
2018 <div class="content">
2019 <pre>template<class L, template<class...> class F> using mp_transform_front =
2023 <div class="paragraph">
2024 <p><code>mp_transform_front<L, F></code> replaces the first element <code>T1</code> of the list <code>L</code> with <code>F<T1></code>.</p>
2028 <h4 id="mp_transform_front_ql_q">mp_transform_front_q<L, Q></h4>
2029 <div class="literalblock">
2030 <div class="content">
2031 <pre>template<class L, class Q> using mp_transform_front_q =
2032 mp_transform_front<L, Q::template fn>;</pre>
2035 <div class="paragraph">
2036 <p>As <code>mp_transform_front</code>, but takes a quoted metafunction.</p>
2040 <h4 id="mp_transform_firstl_f">mp_transform_first<L, F></h4>
2041 <div class="literalblock">
2042 <div class="content">
2043 <pre>template<class L, template<class...> class F> using mp_transform_first =
2044 mp_transform_front<L, F>;</pre>
2047 <div class="paragraph">
2048 <p><code>mp_transform_first</code> is another name for <code>mp_transform_front</code>.</p>
2052 <h4 id="mp_transform_first_ql_q">mp_transform_first_q<L, Q></h4>
2053 <div class="literalblock">
2054 <div class="content">
2055 <pre>template<class L, class Q> using mp_transform_first_q =
2056 mp_transform_first<L, Q::template fn>;</pre>
2059 <div class="paragraph">
2060 <p>As <code>mp_transform_first</code>, but takes a quoted metafunction.</p>
2064 <h4 id="mp_transform_secondl_f">mp_transform_second<L, F></h4>
2065 <div class="literalblock">
2066 <div class="content">
2067 <pre>template<class L, template<class...> class F> using mp_transform_second =
2071 <div class="paragraph">
2072 <p><code>mp_transform_second<L, F></code> replaces the second element <code>T2</code> of the list <code>L</code> with <code>F<T2></code>.</p>
2076 <h4 id="mp_transform_second_ql_q">mp_transform_second_q<L, Q></h4>
2077 <div class="literalblock">
2078 <div class="content">
2079 <pre>template<class L, class Q> using mp_transform_second_q =
2080 mp_transform_second<L, Q::template fn>;</pre>
2083 <div class="paragraph">
2084 <p>As <code>mp_transform_second</code>, but takes a quoted metafunction.</p>
2088 <h4 id="mp_transform_thirdl_f">mp_transform_third<L, F></h4>
2089 <div class="literalblock">
2090 <div class="content">
2091 <pre>template<class L, template<class...> class F> using mp_transform_third =
2095 <div class="paragraph">
2096 <p><code>mp_transform_third<L, F></code> replaces the third element <code>T3</code> of the list <code>L</code> with <code>F<T3></code>.</p>
2100 <h4 id="mp_transform_third_ql_q">mp_transform_third_q<L, Q></h4>
2101 <div class="literalblock">
2102 <div class="content">
2103 <pre>template<class L, class Q> using mp_transform_third_q =
2104 mp_transform_third<L, Q::template fn>;</pre>
2107 <div class="paragraph">
2108 <p>As <code>mp_transform_third</code>, but takes a quoted metafunction.</p>
2113 <h3 id="utility">Utility Components, <boost/mp11/utility.hpp></h3>
2115 <h4 id="mp_identityt">mp_identity<T></h4>
2116 <div class="literalblock">
2117 <div class="content">
2118 <pre>template<class T> struct mp_identity
2124 <div class="paragraph">
2125 <p><code>mp_identity</code> is a simple <em>transformation type trait</em> (as per the C++ standard)
2126 that just returns the same type. It’s useful both as such, and as a type wrapper
2127 for passing types as values to functions.</p>
2129 <div class="listingblock">
2130 <div class="title">Code Example 36. Using mp_identity as a type trait</div>
2131 <div class="content">
2132 <pre class="highlight"><code>template<class T> using addp_if_not_ref =
2133 typename mp_if<std::is_reference<T>, mp_identity<T>, std::add_pointer<T>>::type;</code></pre>
2136 <div class="listingblock">
2137 <div class="title">Code Example 37. Using mp_identity to protect qualifiers and references</div>
2138 <div class="content">
2139 <pre class="highlight"><code>template<class T> void print1()
2141 std::cout << typeid(T).name() << std::endl;
2144 template<class T> void print2()
2146 std::cout << typeid(mp_identity<T>).name() << std::endl;
2151 print1<int const&>(); // 'int'
2152 print2<int const&>(); // 'mp_identity<int const &>'
2158 <h4 id="mp_identity_tt">mp_identity_t<T></h4>
2159 <div class="literalblock">
2160 <div class="content">
2161 <pre>template<class T> using mp_identity_t = typename mp_identity<T>::type;</pre>
2166 <h4 id="mp_inheritt">mp_inherit<T…​></h4>
2167 <div class="literalblock">
2168 <div class="content">
2169 <pre>template<class... T> struct mp_inherit: T... {};</pre>
2174 <h4 id="mp_if_cc_t_e">mp_if_c<C, T, E…​></h4>
2175 <div class="literalblock">
2176 <div class="content">
2177 <pre>template<bool C, class T, class... E> using mp_if_c = /*...*/;</pre>
2180 <div class="paragraph">
2181 <p><code>mp_if_c<true, T, E…​></code> is an alias for <code>T</code>. <code>mp_if_c<false, T, E></code> is an alias for <code>E</code>. Otherwise, the result is a substitution failure.</p>
2183 <div class="listingblock">
2184 <div class="title">Code Example 38. Using mp_if_c to select between two alternatives</div>
2185 <div class="content">
2186 <pre class="highlight"><code>using R1 = mp_if_c<true, int, void>; // int
2188 using R2 = mp_if_c<false, int, void>; // void</code></pre>
2191 <div class="listingblock">
2192 <div class="title">Code Example 39. Using mp_if_c to fail substitution when a condition is not met</div>
2193 <div class="content">
2194 <pre class="highlight"><code>template<class I> using void_if_5 = mp_if_c<I::value == 5, void>;</code></pre>
2197 <div class="paragraph">
2198 <p>This example returns <code>void</code> when <code>I::value</code> is 5, and generates a substitution failure
2199 otherwise. It’s the same as <code>std::enable_if_t<I::value == 5></code> in C++14, or
2200 <code>typename std::enable_if<I::value == 5>::type</code> in C++11.</p>
2204 <h4 id="mp_ifc_t_e">mp_if<C, T, E…​></h4>
2205 <div class="literalblock">
2206 <div class="content">
2207 <pre>template<class C, class T, class... E> using mp_if =
2208 mp_if_c<static_cast<bool>(C::value), T, E...>;</pre>
2211 <div class="paragraph">
2212 <p>Like <code>mp_if_c</code>, but the first argument is a type.</p>
2214 <div class="listingblock">
2215 <div class="title">Code Example 40. Using mp_if to select between two alternatives</div>
2216 <div class="content">
2217 <pre class="highlight"><code>using R1 = mp_if<mp_true, int, void>; // int
2219 using R2 = mp_if<mp_false, int, void>; // void</code></pre>
2222 <div class="listingblock">
2223 <div class="title">Code Example 41. Using mp_if to fail substitution when a condition is not met</div>
2224 <div class="content">
2225 <pre class="highlight"><code>template<class T> using void_if_const = mp_if<std::is_const<T>, void>;
2227 template<class... T> using void_if_all_const =
2228 mp_if<mp_all<std::is_const<T>...>, void>;
2230 template<class T> using if_non_const = mp_if<mp_not<std::is_const<T>>, T>;</code></pre>
2235 <h4 id="mp_eval_if_cc_t_f_u">mp_eval_if_c<C, T, F, U…​></h4>
2236 <div class="literalblock">
2237 <div class="content">
2238 <pre>template<bool C, class T, template<class...> class F, class... U> using mp_eval_if_c =
2242 <div class="paragraph">
2243 <p><code>mp_eval_if_c<C, T, F, U…​></code> is an alias for <code>T</code> when <code>C</code> is <code>true</code>, for <code>F<U…​></code> otherwise. Its purpose
2244 is to avoid evaluating <code>F<U…​></code> when the condition is <code>true</code> as it may not be valid in this case.</p>
2246 <div class="listingblock">
2247 <div class="title">Code Example 42. Using mp_eval_if_c to select the first pack element, or void</div>
2248 <div class="content">
2249 <pre class="highlight"><code>template<class... T> using first_or_void =
2250 mp_eval_if_c<sizeof...(T) == 0, void, mp_apply, mp_first, mp_list<T...>>;</code></pre>
2255 <h4 id="mp_eval_ifc_t_f_u">mp_eval_if<C, T, F, U…​></h4>
2256 <div class="literalblock">
2257 <div class="content">
2258 <pre>template<class C, class T, template<class...> class F, class... U> using mp_eval_if =
2259 mp_eval_if_c<static_cast<bool>(C::value), T, F, U...>;</pre>
2262 <div class="paragraph">
2263 <p>Like <code>mp_eval_if_c</code>, but the first argument is a type.</p>
2265 <div class="listingblock">
2266 <div class="title">Code Example 43. Using mp_eval_if to select the first list element, or void</div>
2267 <div class="content">
2268 <pre class="highlight"><code>template<class L> using first_or_void = mp_eval_if<mp_empty<L>, void, mp_first, L>;</code></pre>
2273 <h4 id="mp_eval_if_qc_t_q_u">mp_eval_if_q<C, T, Q, U…​></h4>
2274 <div class="literalblock">
2275 <div class="content">
2276 <pre>template<class C, class T, class Q, class... U> using mp_eval_if_q =
2277 mp_eval_if<C, T, Q::template fn, U...>;</pre>
2280 <div class="paragraph">
2281 <p>Like <code>mp_eval_if</code>, but takes a quoted metafunction.</p>
2285 <h4 id="mp_eval_if_notc_t_f_u">mp_eval_if_not<C, T, F, U…​></h4>
2286 <div class="literalblock">
2287 <div class="content">
2288 <pre>template<class C, class T, template<class...> class F, class... U>
2289 using mp_eval_if_not = mp_eval_if<mp_not<C>, T, F, U...>;</pre>
2292 <div class="paragraph">
2293 <p>Same as <code>mp_eval_if</code>, but the condition is reversed.</p>
2297 <h4 id="mp_eval_if_not_qc_t_q_u">mp_eval_if_not_q<C, T, Q, U…​></h4>
2298 <div class="literalblock">
2299 <div class="content">
2300 <pre>template<class C, class T, class Q, class... U> using mp_eval_if_not_q =
2301 mp_eval_if_not<C, T, Q::template fn, U...>;</pre>
2304 <div class="paragraph">
2305 <p>Same as <code>mp_eval_if_not</code>, but takes a quoted metafunction.</p>
2309 <h4 id="mp_validf_t">mp_valid<F, T…​></h4>
2310 <div class="literalblock">
2311 <div class="content">
2312 <pre>template<template<class...> class F, class... T> using mp_valid = /*...*/;</pre>
2315 <div class="paragraph">
2316 <p><code>mp_valid<F, T…​></code> is an alias for <code>mp_true</code> when <code>F<T…​></code> is a valid expression, for <code>mp_false</code> otherwise.</p>
2318 <div class="listingblock">
2319 <div class="title">Code Example 44. Using mp_valid to write a metafunction that checks for the existence of a nested type</div>
2320 <div class="content">
2321 <pre class="highlight"><code>template<class T> using get_nested_type = typename T::type;
2323 template<class T> struct has_nested_type: mp_valid<get_nested_type, T> {};</code></pre>
2328 <h4 id="mp_valid_qq_t">mp_valid_q<Q, T…​></h4>
2329 <div class="literalblock">
2330 <div class="content">
2331 <pre>template<class Q, class... T> using mp_valid_q = mp_valid<Q::template fn, T...>;</pre>
2334 <div class="paragraph">
2335 <p>Like <code>mp_valid</code>, but takes a quoted metafunction.</p>
2339 <h4 id="mp_eval_ort_f_u">mp_eval_or<T, F, U…​></h4>
2340 <div class="literalblock">
2341 <div class="content">
2342 <pre>template<class T, template<class...> class F, class... U> using mp_eval_or =
2343 mp_eval_if_not<mp_valid<F, U...>, T, F, U...>;</pre>
2346 <div class="paragraph">
2347 <p><code>mp_eval_or<T, F, U…​></code> is an alias for <code>F<U…​></code> when this expression is valid, for <code>T</code> otherwise.</p>
2351 <h4 id="mp_eval_or_qt_q_u">mp_eval_or_q<T, Q, U…​></h4>
2352 <div class="literalblock">
2353 <div class="content">
2354 <pre>template<class T, class Q, class... U> using mp_eval_or_q =
2355 mp_eval_or<T, Q::template fn, U...>;</pre>
2358 <div class="paragraph">
2359 <p>Like <code>mp_eval_or</code>, but takes a quoted metafunction.</p>
2363 <h4 id="mp_condc_t_r">mp_cond<C, T, R…​></h4>
2364 <div class="literalblock">
2365 <div class="content">
2366 <pre>template<class C, class T, class... R> using mp_cond = /*...*/;</pre>
2369 <div class="paragraph">
2370 <p><code>mp_cond<C, T, R…​></code> is an alias for <code>T</code> when <code>static_cast<bool>(C::value)</code> is <code>true</code>.
2371 When <code>static_cast<bool>(C::value)</code> is <code>false</code>, it’s an alias for <code>mp_cond<R…​></code>.</p>
2373 <div class="paragraph">
2374 <p>(If <code>static_cast<bool>(C::value)</code> is a substitution failure, the result is too a substitution
2377 <div class="listingblock">
2378 <div class="title">Code Example 45. Using mp_cond</div>
2379 <div class="content">
2380 <pre class="highlight"><code>template<int N> using unsigned_ = mp_cond<
2381 mp_bool<N == 8>, uint8_t,
2382 mp_bool<N == 16>, uint16_t,
2383 mp_bool<N == 32>, uint32_t,
2384 mp_bool<N == 64>, uint64_t,
2385 mp_true, unsigned // default case
2391 <h4 id="mp_deferf_t">mp_defer<F, T…​></h4>
2392 <div class="literalblock">
2393 <div class="content">
2394 <pre>template<template<class...> class F, class... T> using mp_defer = /*...*/;</pre>
2397 <div class="paragraph">
2398 <p>When <code>mp_valid<F, T…​></code> is <code>mp_true</code>, <code>mp_defer<F, T…​></code> is a struct with a nested type <code>type</code> which is an alias for <code>F<T…​></code>. Otherwise,
2399 <code>mp_defer<F, T…​></code> is an empty struct.</p>
2403 <h4 id="mp_quotef">mp_quote<F></h4>
2404 <div class="literalblock">
2405 <div class="content">
2406 <pre>template<template<class...> class F> struct mp_quote
2408 template<class... T> using fn = F<T...>;
2412 <div class="paragraph">
2413 <p><code>mp_quote<F></code> transforms the template <code>F</code> into a <em>quoted metafunction</em>, a type with a nested template <code>fn</code> such that <code>fn<T…​></code> returns <code>F<T…​></code>.</p>
2415 <div class="listingblock">
2416 <div class="title">Code Example 46. Using mp_quote to make a list of metafunctions</div>
2417 <div class="content">
2418 <pre class="highlight"><code>using LQ = mp_list<mp_quote<std::is_const>, mp_quote<std::is_volatile>>;</code></pre>
2423 <h4 id="mp_quote_traitf">mp_quote_trait<F></h4>
2424 <div class="literalblock">
2425 <div class="content">
2426 <pre>template<template<class...> class F> struct mp_quote_trait
2428 template<class... T> using fn = typename F<T...>::type;
2432 <div class="paragraph">
2433 <p><code>mp_quote_trait<F></code> transforms the C++03-style trait <code>F</code> into a quoted metafunction.</p>
2435 <div class="listingblock">
2436 <div class="title">Code Example 47. Using mp_quote_trait with std::add_pointer</div>
2437 <div class="content">
2438 <pre class="highlight"><code>using L1 = mp_list<int, void, float>;
2439 using R1 = mp_transform_q<mp_quote_trait<std::add_pointer>, L1>;
2440 // mp_list<int*, void*, float*></code></pre>
2445 <h4 id="mp_invoke_qq_t">mp_invoke_q<Q, T…​></h4>
2446 <div class="literalblock">
2447 <div class="content">
2448 <pre>template<class Q, class... T> using mp_invoke_q = typename Q::template fn<T...>;</pre>
2451 <div class="paragraph">
2452 <p><code>mp_invoke_q<Q, T…​></code> evaluates the nested template <code>fn</code> of a quoted metafunction. <code>mp_invoke_q<mp_quote<F>, T…​></code> returns <code>F<T…​></code>.</p>
2454 <div class="listingblock">
2455 <div class="title">Code Example 48. Using mp_invoke_q to invoke a list of metafunctions, technique 1</div>
2456 <div class="content">
2457 <pre class="highlight"><code>using LQ = mp_list<mp_quote<std::is_const>, mp_quote<std::is_volatile>>;
2459 template<class T> using is_const_and_volatile =
2460 mp_all<mp_product<mp_invoke_q, LQ, mp_list<T>>>;</code></pre>
2463 <div class="listingblock">
2464 <div class="title">Code Example 49. Using mp_invoke_q to invoke a list of metafunctions, technique 2</div>
2465 <div class="content">
2466 <pre class="highlight"><code>template<class T> using is_const_and_volatile =
2467 mp_all<mp_transform_q<mp_bind_back<mp_invoke_q, T>, LQ>>;</code></pre>
2470 <div class="listingblock">
2471 <div class="title">Code Example 50. Using mp_invoke_q to invoke a list of metafunctions, technique 3</div>
2472 <div class="content">
2473 <pre class="highlight"><code>template<class T> using is_const_and_volatile =
2474 mp_all<mp_transform<mp_invoke_q, LQ, mp_fill<LQ, T>>>;</code></pre>
2479 <h4 id="mp_not_fnp">mp_not_fn<P></h4>
2480 <div class="literalblock">
2481 <div class="content">
2482 <pre>template<template<class...> class P> struct mp_not_fn
2484 template<class... T> using fn = mp_not<P<T...>>;
2488 <div class="paragraph">
2489 <p><code>mp_not_fn<P></code> returns a quoted metafunction <code>Q</code> such that <code>Q::fn<T…​></code> returns <code>mp_not<P<T…​>></code>.</p>
2491 <div class="paragraph">
2492 <p>That is, it negates the result of <code>P</code>.</p>
2496 <h4 id="mp_not_fn_qq">mp_not_fn_q<Q></h4>
2497 <div class="literalblock">
2498 <div class="content">
2499 <pre>template<class Q> using mp_not_fn_q = mp_not_fn<Q::template fn>;</pre>
2502 <div class="paragraph">
2503 <p>As <code>mp_not_fn</code>, but takes a quoted metafunction.</p>
2508 <h3 id="algorithm">Algorithms, <boost/mp11/algorithm.hpp></h3>
2510 <h4 id="mp_transformf_l">mp_transform<F, L…​></h4>
2511 <div class="literalblock">
2512 <div class="content">
2513 <pre>template<template<class...> class F, class... L> using mp_transform = /*...*/;</pre>
2516 <div class="paragraph">
2517 <p><code>mp_transform<F, L1<T1…​>, L2<T2…​>, …​, Ln<Tn…​>></code> applies <code>F</code> to each successive tuple of elements and returns <code>L1<F<T1, T2, …​, Tn>…​></code>.</p>
2519 <div class="listingblock">
2520 <div class="title">Code Example 51. Using mp_transform to produce a list of pointers from a list of pointees</div>
2521 <div class="content">
2522 <pre class="highlight"><code>template<class T> using add_pointer_t =
2523 typename std::add_pointer<T>::type; // std::add_pointer_t in C++14
2525 using L1 = std::tuple<void, int, float>;
2526 using R1 = mp_transform<add_pointer_t, L1>; // std::tuple<void*, int*, float*></code></pre>
2529 <div class="listingblock">
2530 <div class="title">Code Example 52. Using mp_transform to compare the contents of two lists of types</div>
2531 <div class="content">
2532 <pre class="highlight"><code>using L1 = std::tuple<void, int, float>;
2533 using L2 = mp_list<void, int, float>;
2535 using R1 = mp_all<mp_transform<std::is_same, L1, L2>>; // mp_true</code></pre>
2538 <div class="listingblock">
2539 <div class="title">Code Example 53. Using mp_transform to compare the contents of two lists of integral constants</div>
2540 <div class="content">
2541 <pre class="highlight"><code>template<class T1, class T2> using eq = mp_bool<T1::value == T2::value>;
2543 using L1 = std::tuple<mp_int<1>, mp_int<2>, mp_int<3>>;
2544 using L2 = mp_list<mp_size_t<1>, mp_size_t<2>, mp_size_t<3>>;
2546 using R1 = mp_all<mp_transform<eq, L1, L2>>; // mp_true</code></pre>
2549 <table class="tableblock frame-all grid-all" style="width: 85%;">
2550 <caption class="title">Illustration 1. mp_transform on one list</caption>
2552 <col style="width: 50%;">
2553 <col style="width: 12.5%;">
2554 <col style="width: 12.5%;">
2555 <col style="width: 12.5%;">
2556 <col style="width: 12.5%;">
2560 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2561 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2562 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2563 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2564 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2567 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2570 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform<F, L1></strong></code></p></td>
2571 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>1</sub>></code></p></td>
2572 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>2</sub>></code></p></td>
2573 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2574 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>n</sub>></code></p></td>
2578 <table class="tableblock frame-all grid-all" style="width: 85%;">
2579 <caption class="title">Illustration 2. mp_transform on two lists</caption>
2581 <col style="width: 50%;">
2582 <col style="width: 12.5%;">
2583 <col style="width: 12.5%;">
2584 <col style="width: 12.5%;">
2585 <col style="width: 12.5%;">
2589 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2590 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2591 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2592 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2593 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2596 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2599 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
2600 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
2601 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2602 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2603 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>n</sub></code></p></td>
2606 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2609 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform<F, L1, L2></strong></code></p></td>
2610 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>1</sub>,B<sub>1</sub>></code></p></td>
2611 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>2</sub>,B<sub>2</sub>></code></p></td>
2612 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2613 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>n</sub>,B<sub>n</sub>></code></p></td>
2619 <h4 id="mp_transform_qq_l">mp_transform_q<Q, L…​></h4>
2620 <div class="literalblock">
2621 <div class="content">
2622 <pre>template<class Q, class... L> using mp_transform_q =
2623 mp_transform<Q::template fn, L...>;</pre>
2626 <div class="paragraph">
2627 <p>As <code>mp_transform</code>, but takes a quoted metafunction.</p>
2629 <div class="listingblock">
2630 <div class="title">Code Example 54. Using mp_transform_q to count the occurrences of <code>void</code> in a list</div>
2631 <div class="content">
2632 <pre class="highlight"><code>using L1 = std::tuple<void, int, float, void, int>;
2634 using R1 = mp_apply<mp_plus,
2635 mp_transform_q<mp_bind_front<std::is_same, void>, L1>>; // mp_int<2></code></pre>
2638 <table class="tableblock frame-all grid-all" style="width: 85%;">
2639 <caption class="title">Illustration 3. mp_transform_q on two lists</caption>
2641 <col style="width: 50%;">
2642 <col style="width: 12.5%;">
2643 <col style="width: 12.5%;">
2644 <col style="width: 12.5%;">
2645 <col style="width: 12.5%;">
2649 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2650 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2651 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2652 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2653 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2656 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2659 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
2660 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
2661 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2662 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2663 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>n</sub></code></p></td>
2666 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2669 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform_q<Q, L1, L2></strong></code></p></td>
2670 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>Q::fn<A<sub>1</sub>,B<sub>1</sub>></code></p></td>
2671 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>Q::fn<A<sub>2</sub>,B<sub>2</sub>></code></p></td>
2672 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2673 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>Q::fn<A<sub>n</sub>,B<sub>n</sub>></code></p></td>
2679 <h4 id="mp_transform_ifp_f_l">mp_transform_if<P, F, L…​></h4>
2680 <div class="literalblock">
2681 <div class="content">
2682 <pre>template<template<class...> class P, template<class...> class F, class... L>
2683 using mp_transform_if = /*...*/;</pre>
2686 <div class="paragraph">
2687 <p><code>mp_transform_if<P, F, L1, L2, …​, Ln></code> replaces the elements of the list <code>L1</code> for which <code>mp_to_bool<P<T1, T2, …​, Tn>></code> is <code>mp_true</code> with
2688 <code>F<T1, T2, …​, Tn></code>, and returns the result, where <code>Ti</code> are the corresponding elements of <code>Li</code>.</p>
2690 <div class="listingblock">
2691 <div class="title">Code Example 55. Using mp_transform_if to replace the occurrences of 'void' in a list with the corresponding elements of a second list</div>
2692 <div class="content">
2693 <pre class="highlight"><code>using L1 = std::tuple<void, int, float, void, int>;
2694 using L2 = std::tuple<char[1], char[2], char[3], char[4], char[5]>;
2696 template<class T1, class T2> using first_is_void = std::is_same<T1, void>;
2697 template<class T1, class T2> using second = T2;
2699 using R1 = mp_transform_if<first_is_void, second, L1, L2>;
2700 // std::tuple<char[1], int, float, char[4], int></code></pre>
2703 <table class="tableblock frame-all grid-all" style="width: 85%;">
2704 <caption class="title">Illustration 4. mp_transform_if</caption>
2706 <col style="width: 50%;">
2707 <col style="width: 12.5%;">
2708 <col style="width: 12.5%;">
2709 <col style="width: 12.5%;">
2710 <col style="width: 12.5%;">
2714 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2715 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2716 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2717 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2718 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2721 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2724 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
2725 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
2726 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2727 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2728 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>n</sub></code></p></td>
2731 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2734 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>P<A<sub>i</sub>, B<sub>i</sub>></strong></code></p></td>
2735 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
2736 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_true</code></p></td>
2737 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2738 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
2741 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2744 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform_if<P, F, L1, L2></strong></code></p></td>
2745 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2746 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>2</sub>,B<sub>2</sub>></code></p></td>
2747 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2748 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2754 <h4 id="mp_transform_if_qqp_qf_l">mp_transform_if_q<Qp, Qf, L…​></h4>
2755 <div class="literalblock">
2756 <div class="content">
2757 <pre>template<class Qp, class Qf, class... L> using mp_transform_if_q =
2758 mp_transform_if<Qp::template fn, Qf::template fn, L...>;</pre>
2761 <div class="paragraph">
2762 <p>As <code>mp_transform_if</code>, but takes quoted metafunctions.</p>
2764 <div class="listingblock">
2765 <div class="title">Code Example 56. Using mp_transform_if_q to replace the occurrences of 'void' in a list with the corresponding elements of a second list</div>
2766 <div class="content">
2767 <pre class="highlight"><code>using L1 = std::tuple<void, int, float, void, int>;
2768 using L2 = std::tuple<char[1], char[2], char[3], char[4], char[5]>;
2770 using R1 = mp_transform_if_q<mp_bind<std::is_same, _1, void>, _2, L1, L2>;
2771 // std::tuple<char[1], int, float, char[4], int></code></pre>
2774 <table class="tableblock frame-all grid-all" style="width: 85%;">
2775 <caption class="title">Illustration 5. mp_transform_if_q</caption>
2777 <col style="width: 50%;">
2778 <col style="width: 12.5%;">
2779 <col style="width: 12.5%;">
2780 <col style="width: 12.5%;">
2781 <col style="width: 12.5%;">
2785 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2786 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2787 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2788 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2789 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2792 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2795 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
2796 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
2797 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2798 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2799 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>n</sub></code></p></td>
2802 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2805 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>Qp::fn<A<sub>i</sub>, B<sub>i</sub>></strong></code></p></td>
2806 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
2807 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_true</code></p></td>
2808 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2809 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
2812 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2815 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_transform_if_q<Qp, _2, L1, L2></strong></code></p></td>
2816 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2817 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
2818 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2819 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2825 <h4 id="mp_filterp_l">mp_filter<P, L…​></h4>
2826 <div class="literalblock">
2827 <div class="content">
2828 <pre>template<template<class...> class P, class... L> using mp_filter = /*...*/;</pre>
2831 <div class="paragraph">
2832 <p><code>mp_filter<P, L1, L2, …​, Ln></code> removes the elements of the list <code>L1</code> for which <code>mp_to_bool<P<T1, T2, …​, Tn>></code>
2833 is <code>mp_false</code> and returns the result, where <code>Ti</code> are the corresponding elements of <code>Li</code>.</p>
2835 <div class="paragraph">
2836 <p>See also <code>mp_copy_if</code> and <code>mp_remove_if</code>, less general variants of <code>mp_filter</code> that only take a single list.</p>
2840 <h4 id="mp_filter_qqp_l">mp_filter_q<Qp, L…​></h4>
2841 <div class="literalblock">
2842 <div class="content">
2843 <pre>template<class Qp, class... L> using mp_filter_q =
2844 mp_filter<Qp::template fn, L...>;</pre>
2847 <div class="paragraph">
2848 <p>As <code>mp_filter</code>, but takes a quoted metafunction.</p>
2850 <div class="listingblock">
2851 <div class="title">Code Example 57. Using mp_filter_q to pick elements of a list based on a mask in another list</div>
2852 <div class="content">
2853 <pre class="highlight"><code>using L1 = std::tuple<void, int, float>;
2854 using L2 = mp_list<mp_true, mp_false, mp_true>;
2855 using R1 = mp_filter_q<_2, L1, L2>; // std::tuple<void, float></code></pre>
2860 <h4 id="mp_filll_v">mp_fill<L, V></h4>
2861 <div class="literalblock">
2862 <div class="content">
2863 <pre>template<class L, class V> using mp_fill = /*...*/;</pre>
2866 <div class="paragraph">
2867 <p><code>mp_fill<L<T…​>, V></code> returns <code>L<V, V, …​, V></code>, with the result having the same size as the input.</p>
2869 <div class="listingblock">
2870 <div class="title">Code Example 58. Using mp_fill with std::tuple</div>
2871 <div class="content">
2872 <pre class="highlight"><code>using L1 = std::tuple<void, int, float>;
2873 using R1 = mp_fill<L1, double>; // std::tuple<double, double, double></code></pre>
2876 <div class="listingblock">
2877 <div class="title">Code Example 59. Using mp_fill with std::pair</div>
2878 <div class="content">
2879 <pre class="highlight"><code>using L1 = std::pair<int, float>;
2880 using R1 = mp_fill<L1, void>; // std::pair<void, void></code></pre>
2883 <table class="tableblock frame-all grid-all" style="width: 85%;">
2884 <caption class="title">Illustration 6. mp_fill</caption>
2886 <col style="width: 50%;">
2887 <col style="width: 12.5%;">
2888 <col style="width: 12.5%;">
2889 <col style="width: 12.5%;">
2890 <col style="width: 12.5%;">
2894 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
2895 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
2896 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
2897 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2898 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
2901 <td class="tableblock halign-left valign-middle" colspan="5"></td>
2904 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_fill<L1, V></strong></code></p></td>
2905 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>V</code></p></td>
2906 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>V</code></p></td>
2907 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
2908 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>V</code></p></td>
2914 <h4 id="mp_countl_v">mp_count<L, V></h4>
2915 <div class="literalblock">
2916 <div class="content">
2917 <pre>template<class L, class V> using mp_count = /*...*/;</pre>
2920 <div class="paragraph">
2921 <p><code>mp_count<L, V></code> returns <code>mp_size_t<N></code>, where <code>N</code> is the number of elements of <code>L</code> same as <code>V</code>.</p>
2925 <h4 id="mp_count_ifl_p">mp_count_if<L, P></h4>
2926 <div class="literalblock">
2927 <div class="content">
2928 <pre>template<class L, template<class...> class P> using mp_count_if = /*...*/;</pre>
2931 <div class="paragraph">
2932 <p><code>mp_count_if<L, P></code> returns <code>mp_size_t<N></code>, where <code>N</code> is the number of elements <code>T</code> of <code>L</code> for which <code>mp_to_bool<P<T>></code> is <code>mp_true</code>.</p>
2936 <h4 id="mp_count_if_ql_q">mp_count_if_q<L, Q></h4>
2937 <div class="literalblock">
2938 <div class="content">
2939 <pre>template<class L, class Q> using mp_count_if_q = mp_count_if<L, Q::template fn>;</pre>
2942 <div class="paragraph">
2943 <p>As <code>mp_count_if</code>, but takes a quoted metafunction.</p>
2947 <h4 id="mp_containsl_v">mp_contains<L, V></h4>
2948 <div class="literalblock">
2949 <div class="content">
2950 <pre>template<class L, class V> using mp_contains = mp_to_bool<mp_count<L, V>>;</pre>
2953 <div class="paragraph">
2954 <p><code>mp_contains<L, V></code> is <code>mp_true</code> when <code>L</code> contains an element <code>V</code>, <code>mp_false</code> otherwise.</p>
2958 <h4 id="mp_starts_withl1_l2">mp_starts_with<L1, L2></h4>
2959 <div class="literalblock">
2960 <div class="content">
2961 <pre>template<class L1, class L2> using mp_starts_with = /*...*/;</pre>
2964 <div class="paragraph">
2965 <p><code>mp_starts_with<L1, L2></code> is <code>mp_true</code> when <code>L1</code> starts with <code>L2</code>, <code>mp_false</code>
2970 <h4 id="mp_repeat_cl_n">mp_repeat_c<L, N></h4>
2971 <div class="literalblock">
2972 <div class="content">
2973 <pre>template<class L, std::size_t N> using mp_repeat_c = /*...*/;</pre>
2976 <div class="paragraph">
2977 <p><code>mp_repeat_c<L, N></code> returns a list of the same form as <code>L</code> that consists of <code>N</code> concatenated copies of <code>L</code>.</p>
2979 <div class="listingblock">
2980 <div class="title">Code Example 60. Using mp_repeat_c</div>
2981 <div class="content">
2982 <pre class="highlight"><code>using L1 = tuple<int>;
2983 using R1 = mp_repeat_c<L1, 3>; // tuple<int, int, int>
2985 using L2 = pair<int, float>;
2986 using R2 = mp_repeat_c<L2, 1>; // pair<int, float>
2988 using L3 = mp_list<int, float>;
2989 using R3 = mp_repeat_c<L3, 2>; // mp_list<int, float, int, float>
2991 using L4 = mp_list<int, float, double>;
2992 using R4 = mp_repeat_c<L4, 0>; // mp_list<></code></pre>
2997 <h4 id="mp_repeatl_n">mp_repeat<L, N></h4>
2998 <div class="literalblock">
2999 <div class="content">
3000 <pre>template<class L, class N> using mp_repeat = /*...*/;</pre>
3003 <div class="paragraph">
3004 <p>Same as <code>mp_repeat_c</code> but with a type argument <code>N</code>. The number of copies is <code>N::value</code> and must be nonnegative.</p>
3008 <h4 id="mp_productf_l">mp_product<F, L…​></h4>
3009 <div class="literalblock">
3010 <div class="content">
3011 <pre>template<template<class...> class F, class... L> using mp_product = /*...*/;</pre>
3014 <div class="paragraph">
3015 <p><code>mp_product<F, L1<T1…​>, L2<T2…​>, …​, Ln<Tn…​>></code> evaluates <code>F<U1, U2, …​, Un></code> for values <code>Ui</code> taken from
3016 the Cartesian product of the lists, as if the elements <code>Ui</code> are formed by <code>n</code> nested loops, each traversing <code>Li</code>.
3017 It returns a list of the form <code>L1<V…​></code> containing the results of the application of <code>F</code>.</p>
3019 <table class="tableblock frame-all grid-all" style="width: 85%;">
3020 <caption class="title">Illustration 7. mp_product on two lists</caption>
3022 <col style="width: 50%;">
3023 <col style="width: 12.5%;">
3024 <col style="width: 12.5%;">
3025 <col style="width: 12.5%;">
3026 <col style="width: 12.5%;">
3030 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3031 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3032 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
3033 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3034 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3037 <td class="tableblock halign-left valign-middle" colspan="5"></td>
3040 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L2</strong></code></p></td>
3041 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
3042 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
3043 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3044 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>m</sub></code></p></td>
3047 <td class="tableblock halign-left valign-middle" colspan="5"></td>
3050 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_product<F, L1, L2></strong></code></p></td>
3051 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>1</sub>,B<sub>1</sub>></code></p></td>
3052 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>1</sub>,B<sub>2</sub>></code></p></td>
3053 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3054 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>1</sub>,B<sub>m</sub>></code></p></td>
3057 <td class="tableblock halign-left valign-middle"></td>
3058 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>2</sub>,B<sub>1</sub>></code></p></td>
3059 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>2</sub>,B<sub>2</sub>></code></p></td>
3060 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3061 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>2</sub>,B<sub>m</sub>></code></p></td>
3064 <td class="tableblock halign-left valign-middle"></td>
3065 <td class="tableblock halign-center valign-middle" colspan="4"><p class="tableblock"><code>…​</code></p></td>
3068 <td class="tableblock halign-left valign-middle"></td>
3069 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>n</sub>,B<sub>1</sub>></code></p></td>
3070 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>n</sub>,B<sub>2</sub>></code></p></td>
3071 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3072 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>F<A<sub>n</sub>,B<sub>m</sub>></code></p></td>
3078 <h4 id="mp_product_qq_l">mp_product_q<Q, L…​></h4>
3079 <div class="literalblock">
3080 <div class="content">
3081 <pre>template<class Q, class... L> using mp_product_q = mp_product<Q::template fn, L...>;</pre>
3084 <div class="paragraph">
3085 <p>As <code>mp_product</code>, but takes a quoted metafunction.</p>
3089 <h4 id="mp_drop_cl_n">mp_drop_c<L, N></h4>
3090 <div class="literalblock">
3091 <div class="content">
3092 <pre>template<class L, std::size_t N> using mp_drop_c = /*...*/;</pre>
3095 <div class="paragraph">
3096 <p><code>mp_drop_c<L, N></code> removes the first <code>N</code> elements of <code>L</code> and returns the result.</p>
3098 <table class="tableblock frame-all grid-all" style="width: 85%;">
3099 <caption class="title">Illustration 8. mp_drop_c</caption>
3101 <col style="width: 40%;">
3102 <col style="width: 10%;">
3103 <col style="width: 10%;">
3104 <col style="width: 10%;">
3105 <col style="width: 10%;">
3106 <col style="width: 10%;">
3107 <col style="width: 10%;">
3111 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3112 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3113 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3114 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3115 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3116 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3117 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3120 <td class="tableblock halign-left valign-middle" colspan="7"></td>
3123 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_drop_c<L1, M></strong></code></p></td>
3124 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3125 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3126 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3127 <td class="tableblock halign-center valign-middle" colspan="3"></td>
3133 <h4 id="mp_dropl_n">mp_drop<L, N></h4>
3134 <div class="literalblock">
3135 <div class="content">
3136 <pre>template<class L, class N> using mp_drop = /*...*/;</pre>
3139 <div class="paragraph">
3140 <p>Same as <code>mp_drop_c</code>, but with a type argument <code>N</code>. <code>N::value</code> must be a nonnegative number.</p>
3144 <h4 id="mp_from_sequences">mp_from_sequence<S></h4>
3145 <div class="literalblock">
3146 <div class="content">
3147 <pre>template<class S> using mp_from_sequence = /*...*/</pre>
3150 <div class="paragraph">
3151 <p><code>mp_from_sequence</code> transforms an integer sequence produced by <code>make_integer_sequence</code> into an <code>mp_list</code>
3152 of the corresponding <code>std::integral_constant</code> types. Given</p>
3154 <div class="literalblock">
3155 <div class="content">
3156 <pre>template<class T, T... I> struct S;</pre>
3159 <div class="paragraph">
3160 <p><code>mp_from_sequence<S<T, I…​>></code> is an alias for <code>mp_list<std::integral_constant<T, I>…​></code>.</p>
3164 <h4 id="mp_iota_cn">mp_iota_c<N></h4>
3165 <div class="literalblock">
3166 <div class="content">
3167 <pre>template<std::size_t N> using mp_iota_c = /*...*/;</pre>
3170 <div class="paragraph">
3171 <p><code>mp_iota_c<N></code> is an alias for <code>mp_list<mp_size_t<0>, mp_size_t<1>, …​, mp_size_t<N-1>></code>.</p>
3175 <h4 id="mp_iotan">mp_iota<N></h4>
3176 <div class="literalblock">
3177 <div class="content">
3178 <pre>template<class N> using mp_iota = /*...*/;</pre>
3181 <div class="paragraph">
3182 <p>Same as <code>mp_iota_c</code>, but with a type argument <code>N</code>. <code>N::value</code> must be a nonnegative number. Returns
3183 <code>mp_list<std::integral_constant<T, 0>, std::integral_constant<T, 1>, …​, std::integral_constant<T, N::value-1>></code>
3184 where <code>T</code> is the type of <code>N::value</code>.</p>
3186 <table class="tableblock frame-all grid-all" style="width: 85%;">
3187 <caption class="title">Illustration 9. mp_iota</caption>
3189 <col style="width: 50%;">
3190 <col style="width: 12.5%;">
3191 <col style="width: 12.5%;">
3192 <col style="width: 12.5%;">
3193 <col style="width: 12.5%;">
3197 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_iota<mp_int<4>></strong></code></p></td>
3198 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_int<0></code></p></td>
3199 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_int<1></code></p></td>
3200 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_int<2></code></p></td>
3201 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_int<3></code></p></td>
3207 <h4 id="mp_at_cl_i">mp_at_c<L, I></h4>
3208 <div class="literalblock">
3209 <div class="content">
3210 <pre>template<class L, std::size_t I> using mp_at_c = /*...*/;</pre>
3213 <div class="paragraph">
3214 <p><code>mp_at_c<L, I></code> returns the <code>I</code>-th element of <code>L</code>, zero-based.</p>
3218 <h4 id="mp_atl_i">mp_at<L, I></h4>
3219 <div class="literalblock">
3220 <div class="content">
3221 <pre>template<class L, class I> using mp_at = /*...*/;</pre>
3224 <div class="paragraph">
3225 <p>Same as <code>mp_at_c</code>, but with a type argument <code>I</code>. <code>I::value</code> must be a nonnegative number.</p>
3229 <h4 id="mp_take_cl_n">mp_take_c<L, N></h4>
3230 <div class="literalblock">
3231 <div class="content">
3232 <pre>template<class L, std::size_t N> using mp_take_c = /*...*/;</pre>
3235 <div class="paragraph">
3236 <p><code>mp_take_c<L, N></code> returns a list of the same form as <code>L</code> containing the first <code>N</code> elements of <code>L</code>.</p>
3238 <table class="tableblock frame-all grid-all" style="width: 85%;">
3239 <caption class="title">Illustration 10. mp_take_c</caption>
3241 <col style="width: 40%;">
3242 <col style="width: 10%;">
3243 <col style="width: 10%;">
3244 <col style="width: 10%;">
3245 <col style="width: 10%;">
3246 <col style="width: 10%;">
3247 <col style="width: 10%;">
3251 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3252 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3253 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3254 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3255 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3256 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3257 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3260 <td class="tableblock halign-left valign-middle" colspan="7"></td>
3263 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_take_c<L1, M></strong></code></p></td>
3264 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3265 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3266 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3267 <td class="tableblock halign-center valign-middle" colspan="3"></td>
3273 <h4 id="mp_takel_n">mp_take<L, N></h4>
3274 <div class="literalblock">
3275 <div class="content">
3276 <pre>template<class L, class N> using mp_take = /*...*/;</pre>
3279 <div class="paragraph">
3280 <p>Same as <code>mp_take_c</code>, but with a type argument <code>N</code>. <code>N::value</code> must be a nonnegative number.</p>
3284 <h4 id="mp_backl">mp_back<L></h4>
3285 <div class="literalblock">
3286 <div class="content">
3287 <pre>template<class L> using mp_back = mp_at_c<L, mp_size<L>::value - 1>;</pre>
3290 <div class="paragraph">
3291 <p><code>mp_back<L></code> returns the last element of the list <code>L</code>.</p>
3295 <h4 id="mp_pop_backl">mp_pop_back<L></h4>
3296 <div class="literalblock">
3297 <div class="content">
3298 <pre>template<class L> using mp_pop_back = mp_take_c<L, mp_size<L>::value - 1>;</pre>
3301 <div class="paragraph">
3302 <p><code>mp_pop_back<L></code> removes the last element of the list <code>L</code> and returns the result.</p>
3306 <h4 id="mp_insert_cl_i_t">mp_insert_c<L, I, T…​></h4>
3307 <div class="literalblock">
3308 <div class="content">
3309 <pre>template<class L, std::size_t I, class... T> using mp_insert_c =
3310 mp_append<mp_take_c<L, I>, mp_push_front<mp_drop_c<L, I>, T...>>;</pre>
3313 <div class="paragraph">
3314 <p>Inserts the elements <code>T…​</code> into the list <code>L</code> at position <code>I</code> (a zero-based index).</p>
3316 <table class="tableblock frame-all grid-all" style="width: 85%;">
3317 <caption class="title">Illustration 11. mp_insert_c with two elements</caption>
3319 <col style="width: 33.3333%;">
3320 <col style="width: 8.3333%;">
3321 <col style="width: 8.3333%;">
3322 <col style="width: 8.3333%;">
3323 <col style="width: 8.3333%;">
3324 <col style="width: 8.3333%;">
3325 <col style="width: 8.3333%;">
3326 <col style="width: 8.3333%;">
3327 <col style="width: 8.3336%;">
3331 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3332 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3333 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3334 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3335 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3336 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3337 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3338 <td class="tableblock halign-center valign-middle" colspan="2"></td>
3341 <td class="tableblock halign-left valign-middle" colspan="9"></td>
3344 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_insert_c<L1, M, B<sub>1</sub>, B<sub>2</sub>></strong></code></p></td>
3345 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3346 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3347 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m</sub></code></p></td>
3348 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>1</sub></code></p></td>
3349 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>B<sub>2</sub></code></p></td>
3350 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>m+1</sub></code></p></td>
3351 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3352 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3358 <h4 id="mp_insertl_i_t">mp_insert<L, I, T…​></h4>
3359 <div class="literalblock">
3360 <div class="content">
3361 <pre>template<class L, class I, class... T> using mp_insert =
3362 mp_append<mp_take<L, I>, mp_push_front<mp_drop<L, I>, T...>>;</pre>
3365 <div class="paragraph">
3366 <p>Same as <code>mp_insert_c</code>, but with a type argument <code>I</code>.</p>
3370 <h4 id="mp_erase_cl_i_j">mp_erase_c<L, I, J></h4>
3371 <div class="literalblock">
3372 <div class="content">
3373 <pre>template<class L, std::size_t I, std::size_t J> using mp_erase_c =
3374 mp_append<mp_take_c<L, I>, mp_drop_c<L, J>>;</pre>
3377 <div class="paragraph">
3378 <p>Removes from the list <code>L</code> the elements with indices from <code>I</code> (inclusive) to <code>J</code> (exclusive).</p>
3380 <table class="tableblock frame-all grid-all" style="width: 85%;">
3381 <caption class="title">Illustration 12. mp_erase_c</caption>
3383 <col style="width: 30.7692%;">
3384 <col style="width: 7.6923%;">
3385 <col style="width: 7.6923%;">
3386 <col style="width: 7.6923%;">
3387 <col style="width: 7.6923%;">
3388 <col style="width: 7.6923%;">
3389 <col style="width: 7.6923%;">
3390 <col style="width: 7.6923%;">
3391 <col style="width: 7.6923%;">
3392 <col style="width: 7.6924%;">
3396 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3397 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>0</sub></code></p></td>
3398 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3399 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>i-1</sub></code></p></td>
3400 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>i</sub></code></p></td>
3401 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3402 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>j-1</sub></code></p></td>
3403 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>j</sub></code></p></td>
3404 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3405 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n-1</sub></code></p></td>
3408 <td class="tableblock halign-left valign-middle" colspan="10"></td>
3411 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_erase_c<L1, I, J></strong></code></p></td>
3412 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>0</sub></code></p></td>
3413 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3414 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>i-1</sub></code></p></td>
3415 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>j</sub></code></p></td>
3416 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3417 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n-1</sub></code></p></td>
3418 <td class="tableblock halign-center valign-middle" colspan="3"></td>
3424 <h4 id="mp_erasel_i_j">mp_erase<L, I, J></h4>
3425 <div class="literalblock">
3426 <div class="content">
3427 <pre>template<class L, class I, class J> using mp_erase =
3428 mp_append<mp_take<L, I>, mp_drop<L, J>>;</pre>
3431 <div class="paragraph">
3432 <p>Same as <code>mp_erase_c</code>, but with a type arguments <code>I</code> and <code>J</code>.</p>
3436 <h4 id="mp_replacel_v_w">mp_replace<L, V, W></h4>
3437 <div class="literalblock">
3438 <div class="content">
3439 <pre>template<class L, class V, class W> using mp_replace = /*...*/;</pre>
3442 <div class="paragraph">
3443 <p>Replaces all <code>V</code> elements of <code>L</code> with <code>W</code> and returns the result.</p>
3445 <table class="tableblock frame-all grid-all" style="width: 85%;">
3446 <caption class="title">Illustration 13. mp_replace</caption>
3448 <col style="width: 50%;">
3449 <col style="width: 12.5%;">
3450 <col style="width: 12.5%;">
3451 <col style="width: 12.5%;">
3452 <col style="width: 12.5%;">
3456 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3457 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3458 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>V</code></p></td>
3459 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3460 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3463 <td class="tableblock halign-left valign-middle" colspan="5"></td>
3466 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_replace<L1, V, W></strong></code></p></td>
3467 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3468 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>W</code></p></td>
3469 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3470 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3476 <h4 id="mp_replace_ifl_p_w">mp_replace_if<L, P, W></h4>
3477 <div class="literalblock">
3478 <div class="content">
3479 <pre>template<class L, template<class...> class P, class W> using mp_replace_if = /*...*/;</pre>
3482 <div class="paragraph">
3483 <p>Replaces all <code>T</code> elements of <code>L</code> for which <code>mp_to_bool<P<T>></code> is <code>mp_true</code> with <code>W</code> and returns the result.</p>
3485 <table class="tableblock frame-all grid-all" style="width: 85%;">
3486 <caption class="title">Illustration 14. mp_replace_if</caption>
3488 <col style="width: 50%;">
3489 <col style="width: 12.5%;">
3490 <col style="width: 12.5%;">
3491 <col style="width: 12.5%;">
3492 <col style="width: 12.5%;">
3496 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3497 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3498 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
3499 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3500 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3503 <td class="tableblock halign-left valign-middle" colspan="5"></td>
3506 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>P<A<sub>i</sub>></strong></code></p></td>
3507 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
3508 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_true</code></p></td>
3509 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3510 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>mp_false</code></p></td>
3513 <td class="tableblock halign-left valign-middle" colspan="5"></td>
3516 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_replace_if<L1, P, W></strong></code></p></td>
3517 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3518 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>W</code></p></td>
3519 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3520 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3526 <h4 id="mp_replace_if_ql_q_w">mp_replace_if_q<L, Q, W></h4>
3527 <div class="literalblock">
3528 <div class="content">
3529 <pre>template<class L, class Q, class W> using mp_replace_if_q =
3530 mp_replace_if<L, Q::template fn, W>;</pre>
3533 <div class="paragraph">
3534 <p>As <code>mp_replace_if</code>, but takes a quoted metafunction.</p>
3538 <h4 id="mp_replace_at_cl_i_w">mp_replace_at_c<L, I, W></h4>
3539 <div class="literalblock">
3540 <div class="content">
3541 <pre>template<class L, std::size_t I, class W> using mp_replace_at_c = /*...*/;</pre>
3544 <div class="paragraph">
3545 <p>Replaces the element of <code>L</code> at zero-based index <code>I</code> with <code>W</code> and returns the result.</p>
3549 <h4 id="mp_replace_atl_i_w">mp_replace_at<L, I, W></h4>
3550 <div class="literalblock">
3551 <div class="content">
3552 <pre>template<class L, class I, class W> using mp_replace_at = /*...*/;</pre>
3555 <div class="paragraph">
3556 <p>Same as <code>mp_replace_at_c</code>, but with a type argument <code>I</code>. <code>I::value</code> must be a nonnegative number.</p>
3560 <h4 id="mp_copy_ifl_p">mp_copy_if<L, P></h4>
3561 <div class="literalblock">
3562 <div class="content">
3563 <pre>template<class L, template<class...> class P> using mp_copy_if = /*...*/;</pre>
3566 <div class="paragraph">
3567 <p>Copies the elements <code>T</code> of <code>L</code> for which <code>mp_to_bool<P<T>></code> is <code>mp_true</code> to a new list of the same form and returns it.</p>
3571 <h4 id="mp_copy_if_ql_q">mp_copy_if_q<L, Q></h4>
3572 <div class="literalblock">
3573 <div class="content">
3574 <pre>template<class L, class Q> using mp_copy_if_q = mp_copy_if<L, Q::template fn>;</pre>
3577 <div class="paragraph">
3578 <p>As <code>mp_copy_if</code>, but takes a quoted metafunction.</p>
3582 <h4 id="mp_removel_v">mp_remove<L, V></h4>
3583 <div class="literalblock">
3584 <div class="content">
3585 <pre>template<class L, class V> using mp_remove = /*...*/;</pre>
3588 <div class="paragraph">
3589 <p>Removes all <code>V</code> elements of <code>L</code> and returns the result.</p>
3593 <h4 id="mp_remove_ifl_p">mp_remove_if<L, P></h4>
3594 <div class="literalblock">
3595 <div class="content">
3596 <pre>template<class L, template<class...> class P> using mp_remove_if = /*...*/;</pre>
3599 <div class="paragraph">
3600 <p>Removes all elements <code>T</code> of <code>L</code> for which <code>mp_to_bool<P<T>></code> is <code>mp_true</code> and returns the result.</p>
3604 <h4 id="mp_remove_if_ql_q">mp_remove_if_q<L, Q></h4>
3605 <div class="literalblock">
3606 <div class="content">
3607 <pre>template<class L, class Q> using mp_remove_if_q = mp_remove_if<L, Q::template fn>;</pre>
3610 <div class="paragraph">
3611 <p>As <code>mp_remove_if</code>, but takes a quoted metafunction.</p>
3615 <h4 id="mp_partitionl_p">mp_partition<L, P></h4>
3616 <div class="literalblock">
3617 <div class="content">
3618 <pre>template<class L, template<class...> class P> using mp_partition = /*...*/;</pre>
3621 <div class="paragraph">
3622 <p><code>mp_partition<L<T…​>, P></code> partitions <code>L</code> into two lists <code>L<U1…​></code> and <code>L<U2…​></code> such that <code>mp_to_bool<P<T>></code> is <code>mp_true</code>
3623 for the elements of <code>L<U1…​></code> and <code>mp_false</code> for the elements of <code>L<U2…​></code>. Returns <code>L<L<U1…​>, L<U2…​>></code>.</p>
3627 <h4 id="mp_partition_ql_q">mp_partition_q<L, Q></h4>
3628 <div class="literalblock">
3629 <div class="content">
3630 <pre>template<class L, class Q> using mp_partition_q = mp_partition<L, Q::template fn>;</pre>
3633 <div class="paragraph">
3634 <p>As <code>mp_partition</code>, but takes a quoted metafunction.</p>
3638 <h4 id="mp_sortl_p">mp_sort<L, P></h4>
3639 <div class="literalblock">
3640 <div class="content">
3641 <pre>template<class L, template<class...> class P> using mp_sort = /*...*/;</pre>
3644 <div class="paragraph">
3645 <p><code>mp_sort<L, P></code> sorts the list <code>L</code> according to the strict weak ordering <code>mp_to_bool<P<T, U>></code>.</p>
3647 <div class="listingblock">
3648 <div class="title">Code Example 61. Using mp_sort to sort a list of std::ratio values</div>
3649 <div class="content">
3650 <pre>#include <ratio>
3652 using L1 = mp_list<std::ratio<1,2>, std::ratio<1,4>>;
3653 using R1 = mp_sort<L1, std::ratio_less>; // mp_list<ratio<1,4>, ratio<1,2>></pre>
3658 <h4 id="mp_sort_ql_q">mp_sort_q<L, Q></h4>
3659 <div class="literalblock">
3660 <div class="content">
3661 <pre>template<class L, class Q> using mp_sort_q = mp_sort<L, Q::template fn>;</pre>
3664 <div class="paragraph">
3665 <p>As <code>mp_sort</code>, but takes a quoted metafunction.</p>
3669 <h4 id="mp_nth_element_cl_i_p">mp_nth_element_c<L, I, P></h4>
3670 <div class="literalblock">
3671 <div class="content">
3672 <pre>template<class L, std::size_t I, template<class...> class P> using mp_nth_element_c =
3676 <div class="paragraph">
3677 <p>Returns the element at position <code>I</code> in <code>mp_sort<L, P></code>.</p>
3681 <h4 id="mp_nth_elementl_i_p">mp_nth_element<L, I, P></h4>
3682 <div class="literalblock">
3683 <div class="content">
3684 <pre>template<class L, class I, template<class...> class P> using mp_nth_element = /*...*/;</pre>
3687 <div class="paragraph">
3688 <p>Like <code>mp_nth_element_c</code>, but with a type argument <code>I</code>. <code>I::value</code> must be a nonnegative number.</p>
3692 <h4 id="mp_nth_element_ql_i_q">mp_nth_element_q<L, I, Q></h4>
3693 <div class="literalblock">
3694 <div class="content">
3695 <pre>template<class L, class I, class Q> using mp_nth_element_q =
3696 mp_nth_element<L, I, Q::template fn>;</pre>
3699 <div class="paragraph">
3700 <p>Like <code>mp_nth_element</code>, but takes a quoted metafunction.</p>
3704 <h4 id="mp_min_elementl_p">mp_min_element<L, P></h4>
3705 <div class="literalblock">
3706 <div class="content">
3707 <pre>template<class L, template<class...> class P> using mp_min_element = /*...*/;</pre>
3710 <div class="paragraph">
3711 <p><code>mp_min_element<L, P></code> returns the minimal element of the list <code>L</code> according to the ordering <code>mp_to_bool<P<T, U>></code>.</p>
3713 <div class="paragraph">
3714 <p>It’s equivalent to <code>mp_fold<mp_rest<L>, mp_first<L>, F></code>, where <code>F<T, U></code> returns <code>mp_if<P<T, U>, T, U></code>.</p>
3718 <h4 id="mp_min_element_ql_q">mp_min_element_q<L, Q></h4>
3719 <div class="literalblock">
3720 <div class="content">
3721 <pre>template<class L, class Q> using mp_min_element_q = mp_min_element<L, Q::template fn>;</pre>
3724 <div class="paragraph">
3725 <p>As <code>mp_min_element</code>, but takes a quoted metafunction.</p>
3729 <h4 id="mp_max_elementl_p">mp_max_element<L, P></h4>
3730 <div class="literalblock">
3731 <div class="content">
3732 <pre>template<class L, template<class...> class P> using mp_max_element = /*...*/;</pre>
3735 <div class="paragraph">
3736 <p><code>mp_max_element<L, P></code> returns the maximal element of the list <code>L</code> according to the ordering <code>mp_to_bool<P<T, U>></code>.</p>
3738 <div class="paragraph">
3739 <p>It’s equivalent to <code>mp_fold<mp_rest<L>, mp_first<L>, F></code>, where <code>F<T, U></code> returns <code>mp_if<P<U, T>, T, U></code>.</p>
3743 <h4 id="mp_max_element_ql_q">mp_max_element_q<L, Q></h4>
3744 <div class="literalblock">
3745 <div class="content">
3746 <pre>template<class L, class Q> using mp_max_element_q = mp_max_element<L, Q::template fn>;</pre>
3749 <div class="paragraph">
3750 <p>As <code>mp_max_element</code>, but takes a quoted metafunction.</p>
3754 <h4 id="mp_findl_v">mp_find<L, V></h4>
3755 <div class="literalblock">
3756 <div class="content">
3757 <pre>template<class L, class V> using mp_find = /*...*/;</pre>
3760 <div class="paragraph">
3761 <p><code>mp_find<L, V></code> returns the index at which the type <code>V</code> is located in the list <code>L</code>. It’s an alias for <code>mp_size_t<I></code>,
3762 where <code>I</code> is the zero-based index of the first occurrence of <code>V</code> in <code>L</code>. If <code>L</code> does not contain <code>V</code>, <code>mp_find<L, V></code>
3763 is <code>mp_size<L></code>.</p>
3767 <h4 id="mp_find_ifl_p">mp_find_if<L, P></h4>
3768 <div class="literalblock">
3769 <div class="content">
3770 <pre>template<class L, template<class...> class P> using mp_find_if = /*...*/;</pre>
3773 <div class="paragraph">
3774 <p><code>mp_find_f<L, P></code> is an alias for <code>mp_size_t<I></code>, where <code>I</code> is the zero-based index of the first element <code>T</code> in <code>L</code> for which
3775 <code>mp_to_bool<P<T>></code> is <code>mp_true</code>. If there is no such element, <code>mp_find_if<L, P></code> is <code>mp_size<L></code>.</p>
3779 <h4 id="mp_find_if_ql_q">mp_find_if_q<L, Q></h4>
3780 <div class="literalblock">
3781 <div class="content">
3782 <pre>template<class L, class Q> using mp_find_if_q = mp_find_if<L, Q::template fn>;</pre>
3785 <div class="paragraph">
3786 <p>As <code>mp_find_if</code>, but takes a quoted metafunction.</p>
3790 <h4 id="mp_reversel">mp_reverse<L></h4>
3791 <div class="literalblock">
3792 <div class="content">
3793 <pre>template<class L> using mp_reverse = /*...*/;</pre>
3796 <div class="paragraph">
3797 <p><code>mp_reverse<L<T1, T2, …​, Tn>></code> is <code>L<Tn, …​, T2, T1></code>.</p>
3799 <table class="tableblock frame-all grid-all" style="width: 85%;">
3800 <caption class="title">Illustration 15. mp_reverse</caption>
3802 <col style="width: 50%;">
3803 <col style="width: 12.5%;">
3804 <col style="width: 12.5%;">
3805 <col style="width: 12.5%;">
3806 <col style="width: 12.5%;">
3810 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>L1</strong></code></p></td>
3811 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3812 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>2</sub></code></p></td>
3813 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3814 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3817 <td class="tableblock halign-left valign-middle" colspan="5"></td>
3820 <td class="tableblock halign-left valign-middle"><p class="tableblock"><code><strong>mp_reverse<L1></strong></code></p></td>
3821 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n</sub></code></p></td>
3822 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>n-1</sub></code></p></td>
3823 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>…​</code></p></td>
3824 <td class="tableblock halign-center valign-middle"><p class="tableblock"><code>A<sub>1</sub></code></p></td>
3830 <h4 id="mp_foldl_v_f">mp_fold<L, V, F></h4>
3831 <div class="literalblock">
3832 <div class="content">
3833 <pre>template<class L, class V, template<class...> class F> using mp_fold = /*...*/;</pre>
3836 <div class="paragraph">
3837 <p><code>mp_fold<L<T1, T2, …​, Tn>, V, F></code> is <code>F< F< F< F<V, T1>, T2>, …​>, Tn></code>, or <code>V</code>, if <code>L</code> is empty.</p>
3839 <div class="listingblock">
3840 <div class="title">Code Example 62. Using mp_fold to add the contents of a list of std::ratio values</div>
3841 <div class="content">
3842 <pre>#include <ratio>
3844 using L1 = mp_list<std::ratio<1,8>, std::ratio<1,4>, std::ratio<1,2>>;
3845 using R1 = mp_fold<L1, std::ratio<0,1>, std::ratio_add>; // std::ratio<7,8></pre>
3850 <h4 id="mp_fold_ql_v_q">mp_fold_q<L, V, Q></h4>
3851 <div class="literalblock">
3852 <div class="content">
3853 <pre>template<class L, class V, class Q> using mp_fold_q =
3854 mp_fold<L, V, Q::template fn>;</pre>
3857 <div class="paragraph">
3858 <p>As <code>mp_fold</code>, but takes a quoted metafunction.</p>
3862 <h4 id="mp_reverse_foldl_v_f">mp_reverse_fold<L, V, F></h4>
3863 <div class="literalblock">
3864 <div class="content">
3865 <pre>template<class L, class V, template<class...> class F> using mp_reverse_fold =
3869 <div class="paragraph">
3870 <p><code>mp_reverse_fold<L<T1, T2, …​, Tn>, V, F></code> is <code>F<T1, F<T2, F<…​, F<Tn, V>>>></code>, or <code>V</code>, if <code>L</code> is empty.</p>
3874 <h4 id="mp_reverse_fold_ql_v_q">mp_reverse_fold_q<L, V, Q></h4>
3875 <div class="literalblock">
3876 <div class="content">
3877 <pre>template<class L, class V, class Q> using mp_reverse_fold_q =
3878 mp_reverse_fold<L, V, Q::template fn>;</pre>
3881 <div class="paragraph">
3882 <p>As <code>mp_reverse_fold</code>, but takes a quoted metafunction.</p>
3886 <h4 id="mp_uniquel">mp_unique<L></h4>
3887 <div class="literalblock">
3888 <div class="content">
3889 <pre>template<class L> using mp_unique = /*...*/;</pre>
3892 <div class="paragraph">
3893 <p><code>mp_unique<L></code> returns a list of the same form as <code>L</code> with the duplicate elements removed.</p>
3897 <h4 id="mp_all_ofl_p">mp_all_of<L, P></h4>
3898 <div class="literalblock">
3899 <div class="content">
3900 <pre>template<class L, template<class...> class P> using mp_all_of =
3901 mp_bool< mp_count_if<L, P>::value == mp_size<L>::value >;</pre>
3904 <div class="paragraph">
3905 <p><code>mp_all_of<L, P></code> is <code>mp_true</code> when <code>P</code> holds for all elements of <code>L</code>, <code>mp_false</code> otherwise. When <code>L</code> is empty, the result is <code>mp_true</code>.</p>
3909 <h4 id="mp_all_of_ql_q">mp_all_of_q<L, Q></h4>
3910 <div class="literalblock">
3911 <div class="content">
3912 <pre>template<class L, class Q> using mp_all_of_q = mp_all_of<L, Q::template fn>;</pre>
3915 <div class="paragraph">
3916 <p>As <code>mp_all_of</code>, but takes a quoted metafunction.</p>
3920 <h4 id="mp_none_ofl_p">mp_none_of<L, P></h4>
3921 <div class="literalblock">
3922 <div class="content">
3923 <pre>template<class L, template<class...> class P> using mp_none_of =
3924 mp_bool< mp_count_if<L, P>::value == 0 >;</pre>
3927 <div class="paragraph">
3928 <p><code>mp_none_of<L, P></code> is <code>mp_true</code> when <code>P</code> holds for no element of <code>L</code>, <code>mp_false</code> otherwise. When <code>L</code> is empty, the result is <code>mp_true</code>.</p>
3932 <h4 id="mp_none_of_ql_q">mp_none_of_q<L, Q></h4>
3933 <div class="literalblock">
3934 <div class="content">
3935 <pre>template<class L, class Q> using mp_none_of_q = mp_none_of<L, Q::template fn>;</pre>
3938 <div class="paragraph">
3939 <p>As <code>mp_none_of</code>, but takes a quoted metafunction.</p>
3943 <h4 id="mp_any_ofl_p">mp_any_of<L, P></h4>
3944 <div class="literalblock">
3945 <div class="content">
3946 <pre>template<class L, template<class...> class P> using mp_any_of =
3947 mp_bool< mp_count_if<L, P>::value != 0 >;</pre>
3950 <div class="paragraph">
3951 <p><code>mp_any_of<L, P></code> is <code>mp_true</code> when <code>P</code> holds for at least one element of <code>L</code>, <code>mp_false</code> otherwise. When <code>L</code> is empty, the result is <code>mp_false</code>.</p>
3955 <h4 id="mp_any_of_ql_q">mp_any_of_q<L, Q></h4>
3956 <div class="literalblock">
3957 <div class="content">
3958 <pre>template<class L, class Q> using mp_any_of_q = mp_any_of<L, Q::template fn>;</pre>
3961 <div class="paragraph">
3962 <p>As <code>mp_any_of</code>, but takes a quoted metafunction.</p>
3966 <h4 id="mp_for_eachlf">mp_for_each<L>(f)</h4>
3967 <div class="literalblock">
3968 <div class="content">
3969 <pre>template<class L, class F> constexpr F mp_for_each(F&& f);</pre>
3972 <div class="paragraph">
3973 <p><code>mp_for_each<L>(f)</code> calls <code>f</code> with <code>T()</code> for each element <code>T</code> of the list <code>L</code>, in order.</p>
3975 <div class="paragraph">
3976 <p>Returns <code>std::forward<F>(f)</code>.</p>
3978 <div class="listingblock">
3979 <div class="title">Code Example 63. Using mp_for_each and a C++14 lambda to print a tuple</div>
3980 <div class="content">
3981 <pre class="highlight"><code>template<class... T> void print( std::tuple<T...> const & tp )
3983 std::size_t const N = sizeof...(T);
3985 mp_for_each<mp_iota_c<N>>( [&]( auto I ){
3987 // I is mp_size_t<0>, mp_size_t<1>, ..., mp_size_t<N-1>
3989 std::cout << std::get<I>(tp) << std::endl;
3997 <h4 id="mp_with_indexni_f">mp_with_index<N>(i, f)</h4>
3998 <div class="literalblock">
3999 <div class="content">
4000 <pre>template<std::size_t N, class F>
4001 constexpr auto mp_with_index( std::size_t i, F && f )
4002 -> decltype(std::declval<F>()(std::declval<mp_size_t<0>>()));</pre>
4005 <div class="paragraph">
4006 <p><code>mp_with_index<N>(i, f)</code> calls <code>f</code> with <code>mp_size_t<i>()</code> and returns the result. <code>i</code> must be less than <code>N</code>.
4007 Only <code>constexpr</code> on C++14 and higher.</p>
4009 <div class="literalblock">
4010 <div class="content">
4011 <pre>template<class N, class F>
4012 constexpr auto mp_with_index( std::size_t i, F && f )
4013 -> decltype(std::declval<F>()(std::declval<mp_size_t<0>>()));</pre>
4016 <div class="paragraph">
4017 <p>Returns <code>mp_with_index<N::value>(i, f)</code>.</p>
4019 <div class="listingblock">
4020 <div class="title">Code Example 64. Using mp_with_index and a C++14 lambda to print the active element of a variant</div>
4021 <div class="content">
4022 <pre class="highlight"><code>template<class... T> void print( std::variant<T...> const& v )
4024 mp_with_index<sizeof...(T)>( v.index(), [&]( auto I ) {
4026 // I is mp_size_t<v.index()>{} here
4028 std::cout << std::get<I>( v ) << std::endl;
4037 <h3 id="set">Set Operations, <boost/mp11/set.hpp></h3>
4038 <div class="paragraph">
4039 <p>A set is a list whose elements are unique.</p>
4042 <h4 id="mp_is_sets">mp_is_set<S></h4>
4043 <div class="literalblock">
4044 <div class="content">
4045 <pre>template<class S> using mp_is_set = /*...*/;</pre>
4048 <div class="paragraph">
4049 <p><code>mp_is_set<S></code> is <code>mp_true</code> if <code>S</code> is a set, <code>mp_false</code> otherwise.</p>
4053 <h4 id="mp_set_containss_v">mp_set_contains<S, V></h4>
4054 <div class="literalblock">
4055 <div class="content">
4056 <pre>template<class S, class V> using mp_set_contains = /*...*/;</pre>
4059 <div class="paragraph">
4060 <p><code>mp_set_contains<S, V></code> is <code>mp_true</code> if the type <code>V</code> is an element of the set <code>S</code>, <code>mp_false</code> otherwise.</p>
4064 <h4 id="mp_set_push_backs_t">mp_set_push_back<S, T…​></h4>
4065 <div class="literalblock">
4066 <div class="content">
4067 <pre>template<class S, class... T> using mp_set_push_back = /*...*/;</pre>
4070 <div class="paragraph">
4071 <p>For each <code>T1</code> in <code>T…​</code>, <code>mp_set_push_back<S, T…​></code> appends <code>T1</code> to the end of the set <code>S</code> if it’s not already an element of <code>S</code>.</p>
4075 <h4 id="mp_set_push_fronts_t">mp_set_push_front<S, T…​></h4>
4076 <div class="literalblock">
4077 <div class="content">
4078 <pre>template<class S, class... T> using mp_set_push_front = /*...*/;</pre>
4081 <div class="paragraph">
4082 <p><code>mp_set_push_front<S, T…​></code> inserts at the front of the set <code>S</code> those elements of <code>T…​</code> for which <code>S</code> does not already contain the same type.</p>
4086 <h4 id="mp_set_unionl">mp_set_union<L…​></h4>
4087 <div class="literalblock">
4088 <div class="content">
4089 <pre>template<class... L> using mp_set_union = /*...*/;</pre>
4092 <div class="paragraph">
4093 <p><code>mp_set_union<S, L…​></code> is <code>mp_set_push_back<S, T…​></code>, where <code>T…​</code> are the combined elements of the lists <code>L…​</code>.
4094 <code>mp_set_union<></code> is <code>mp_list<></code>.</p>
4098 <h4 id="mp_set_intersections">mp_set_intersection<S…​></h4>
4099 <div class="literalblock">
4100 <div class="content">
4101 <pre>template<class... S> using mp_set_intersection = /*...*/;</pre>
4104 <div class="paragraph">
4105 <p><code>mp_set_intersection<S…​></code> returns a set that contains the elements that occur in all of the sets <code>S…​</code>.
4106 <code>mp_set_intersection<></code> is <code>mp_list<></code>.</p>
4110 <h4 id="mp_set_differencel_s">mp_set_difference<L, S…​></h4>
4111 <div class="literalblock">
4112 <div class="content">
4113 <pre>template<class L, class... S> using mp_set_difference = /*...*/;</pre>
4116 <div class="paragraph">
4117 <p><code>mp_set_difference<L, S…​></code> removes the elements of the list <code>L</code> that appear in any of the sets <code>S…​</code> and
4118 returns the result.</p>
4123 <h3 id="map">Map Operations, <boost/mp11/map.hpp></h3>
4124 <div class="paragraph">
4125 <p>A map is a list of lists, the inner lists having at least one element (the key.) The keys of the map must be unique.</p>
4128 <h4 id="mp_is_mapm">mp_is_map<M></h4>
4129 <div class="literalblock">
4130 <div class="content">
4131 <pre>template<class M> using mp_is_map = /*...*/;</pre>
4134 <div class="paragraph">
4135 <p><code>mp_is_map<M></code> is <code>mp_true</code> if <code>M</code> is a map, <code>mp_false</code> otherwise.</p>
4139 <h4 id="mp_map_findm_k">mp_map_find<M, K></h4>
4140 <div class="literalblock">
4141 <div class="content">
4142 <pre>template<class M, class K> using mp_map_find = /*...*/;</pre>
4145 <div class="paragraph">
4146 <p><code>mp_map_find<M, K></code> is an alias for the element of the map <code>M</code> with a key <code>K</code>, or for <code>void</code>, if there is no such element.</p>
4150 <h4 id="mp_map_containsm_k">mp_map_contains<M, K></h4>
4151 <div class="literalblock">
4152 <div class="content">
4153 <pre>template<class M, class K> using mp_map_contains =
4154 mp_not<std::is_same<mp_map_find<M, K>, void>>;</pre>
4157 <div class="paragraph">
4158 <p><code>mp_map_contains<M, K></code> is <code>mp_true</code> if the map <code>M</code> contains an element with a key <code>K</code>, <code>mp_false</code> otherwise.</p>
4162 <h4 id="mp_map_insertm_t">mp_map_insert<M, T></h4>
4163 <div class="literalblock">
4164 <div class="content">
4165 <pre>template<class M, class T> using mp_map_insert =
4166 mp_if< mp_map_contains<M, mp_first<T>>, M, mp_push_back<M, T> >;</pre>
4169 <div class="paragraph">
4170 <p>Inserts the element <code>T</code> into the map <code>M</code>, if an element with a key <code>mp_first<T></code> is not already in <code>M</code>.</p>
4174 <h4 id="mp_map_replacem_t">mp_map_replace<M, T></h4>
4175 <div class="literalblock">
4176 <div class="content">
4177 <pre>template<class M, class T> using mp_map_replace = /*...*/;</pre>
4180 <div class="paragraph">
4181 <p>If the map <code>M</code> does not contain an element with a key <code>mp_first<T></code>, inserts it (using <code>mp_push_back<M, T></code>); otherwise,
4182 replaces the existing element with <code>T</code>.</p>
4186 <h4 id="mp_map_updatem_t_f">mp_map_update<M, T, F></h4>
4187 <div class="literalblock">
4188 <div class="content">
4189 <pre>template<class M, class T, template<class...> class F> using mp_map_update = /*...*/;</pre>
4192 <div class="paragraph">
4193 <p>If the map <code>M</code> does not contain an element with a key <code>mp_first<T></code>, inserts it (using <code>mp_push_back<M, T></code>); otherwise,
4194 replaces the existing element <code>L<X, Y…​></code> with <code>L<X, F<X, Y…​>></code>.</p>
4196 <div class="listingblock">
4197 <div class="title">Code Example 65. Using mp_map_update to count the number of occurrences of types in a list</div>
4198 <div class="content">
4199 <pre class="highlight"><code>template<class T, class U> using inc2nd = mp_int<U::value + 1>;
4201 template<class M, class T> using count_types =
4202 mp_map_update<M, std::pair<T, mp_int<1>>, inc2nd>;
4204 using L1 = mp_list<float, char, float, float, float, float, char, float>;
4206 using R1 = mp_fold<L1, std::tuple<>, count_types>;
4207 // std::tuple<std::pair<float, mp_int<6>>, std::pair<char, mp_int<2>>></code></pre>
4212 <h4 id="mp_map_update_qm_t_q">mp_map_update_q<M, T, Q></h4>
4213 <div class="literalblock">
4214 <div class="content">
4215 <pre>template<class M, class T, class Q> using mp_map_update_q =
4216 mp_map_update<M, T, Q::template fn>;</pre>
4219 <div class="paragraph">
4220 <p>As <code>mp_map_update</code>, but takes a quoted metafunction.</p>
4224 <h4 id="mp_map_erasem_k">mp_map_erase<M, K></h4>
4225 <div class="literalblock">
4226 <div class="content">
4227 <pre>template<class M, class K> using mp_map_erase = /*...*/;</pre>
4230 <div class="paragraph">
4231 <p>If the map <code>M</code> contains an element with a key <code>K</code>, removes it.</p>
4235 <h4 id="mp_map_keysm">mp_map_keys<M></h4>
4236 <div class="literalblock">
4237 <div class="content">
4238 <pre>template<class M> using mp_map_keys = mp_transform<mp_first, M>;</pre>
4241 <div class="paragraph">
4242 <p><code>mp_map_keys<M></code> returns a list of the keys of <code>M</code>. When <code>M</code> is a valid map, the keys are unique, so the result is a set.</p>
4247 <h3 id="function">Helper Metafunctions, <boost/mp11/function.hpp></h3>
4249 <h4 id="mp_voidt">mp_void<T…​></h4>
4250 <div class="literalblock">
4251 <div class="content">
4252 <pre>template<class... T> using mp_void = void;</pre>
4255 <div class="paragraph">
4256 <p>Same as <code>std::void_t</code> from C++17.</p>
4260 <h4 id="mp_andt">mp_and<T…​></h4>
4261 <div class="literalblock">
4262 <div class="content">
4263 <pre>template<class... T> using mp_and = /*...*/;</pre>
4266 <div class="paragraph">
4267 <p><code>mp_and<T…​></code> applies <code>mp_to_bool</code> to the types in <code>T…​</code>, in order. If the result of an application is <code>mp_false</code>, <code>mp_and</code>
4268 returns <code>mp_false</code>. If the application causes a substitution failure, returns <code>mp_false</code>. If all results are <code>mp_true</code>,
4269 returns <code>mp_true</code>. <code>mp_and<></code> is <code>mp_true</code>.</p>
4271 <div class="listingblock">
4272 <div class="title">Code Example 66. mp_and behavior</div>
4273 <div class="content">
4274 <pre class="highlight"><code>using R1 = mp_and<mp_true, mp_true>; // mp_true
4276 using R2 = mp_and<mp_false, void>; // mp_false, void is not reached
4278 using R3 = mp_and<mp_false, mp_false>; // mp_false
4280 using R4 = mp_and<void, mp_true>; // mp_false (!)</code></pre>
4285 <h4 id="mp_allt">mp_all<T…​></h4>
4286 <div class="literalblock">
4287 <div class="content">
4288 <pre>template<class... T> using mp_all = /*...*/;</pre>
4291 <div class="paragraph">
4292 <p><code>mp_all<T…​></code> is <code>mp_true</code> if <code>mp_to_bool<U></code> is <code>mp_true</code> for all types <code>U</code> in <code>T…​</code>, <code>mp_false</code> otherwise. Same as
4293 <code>mp_and</code>, but does not perform short-circuit evaluation. <code>mp_and<mp_false, void></code> is <code>mp_false</code>, but <code>mp_all<mp_false, void></code>
4294 is an error because <code>void</code> does not have a nested <code>value</code>. The upside is that <code>mp_all</code> is potentially faster and does not
4295 mask substitution failures as <code>mp_and</code> does.</p>
4297 <div class="listingblock">
4298 <div class="title">Code Example 67. mp_all behavior</div>
4299 <div class="content">
4300 <pre class="highlight"><code>using R1 = mp_all<mp_true, mp_true>; // mp_true
4302 using R2 = mp_all<mp_false, void>; // compile-time error
4304 using R3 = mp_all<mp_false, mp_false>; // mp_false
4306 using R4 = mp_all<void, mp_true>; // compile-time error</code></pre>
4311 <h4 id="mp_ort">mp_or<T…​></h4>
4312 <div class="literalblock">
4313 <div class="content">
4314 <pre>template<class... T> using mp_or = /*...*/;</pre>
4317 <div class="paragraph">
4318 <p><code>mp_or<T…​></code> applies <code>mp_to_bool</code> to the types in <code>T…​</code>, in order. If the result of an application is <code>mp_true</code>, <code>mp_or</code>
4319 returns <code>mp_true</code>. If all results are <code>mp_false</code>, returns <code>mp_false</code>. <code>mp_or<></code> is <code>mp_false</code>.</p>
4321 <div class="listingblock">
4322 <div class="title">Code Example 68. mp_or behavior</div>
4323 <div class="content">
4324 <pre class="highlight"><code>using R1 = mp_or<mp_true, mp_false>; // mp_true
4326 using R2 = mp_or<mp_true, void>; // mp_true, void is not reached
4328 using R3 = mp_or<mp_false, mp_false>; // mp_false
4330 using R4 = mp_or<void, mp_true>; // compile-time error</code></pre>
4335 <h4 id="mp_anyt">mp_any<T…​></h4>
4336 <div class="literalblock">
4337 <div class="content">
4338 <pre>template<class... T> using mp_any = /*...*/;</pre>
4341 <div class="paragraph">
4342 <p><code>mp_any<T…​></code> is <code>mp_true</code> if <code>mp_to_bool<U></code> is <code>mp_true</code> for any type <code>U</code> in <code>T…​</code>, <code>mp_false</code> otherwise. Same as
4343 <code>mp_or</code>, but does not perform short-circuit evaluation.</p>
4345 <div class="listingblock">
4346 <div class="title">Code Example 69. mp_any behavior</div>
4347 <div class="content">
4348 <pre class="highlight"><code>using R1 = mp_any<mp_true, mp_false>; // mp_true
4350 using R2 = mp_any<mp_true, void>; // compile-time error
4352 using R3 = mp_any<mp_false, mp_false>; // mp_false
4354 using R4 = mp_any<void, mp_true>; // compile-time error</code></pre>
4359 <h4 id="mp_samet">mp_same<T…​></h4>
4360 <div class="literalblock">
4361 <div class="content">
4362 <pre>template<class... T> using mp_same = /*...*/;</pre>
4365 <div class="paragraph">
4366 <p><code>mp_same<T…​></code> is <code>mp_true</code> if all the types in <code>T…​</code> are the same type, <code>mp_false</code> otherwise. <code>mp_same<></code> is <code>mp_true</code>.</p>
4370 <h4 id="mp_similart">mp_similar<T…​></h4>
4371 <div class="literalblock">
4372 <div class="content">
4373 <pre>template<class... T> using mp_similar = /*...*/;</pre>
4376 <div class="paragraph">
4377 <p><code>mp_similar<T…​></code> is <code>mp_true</code> if all the types in <code>T…​</code> are the same type, or instantiations of the same class template
4378 whose parameters are all types, <code>mp_false</code> otherwise. <code>mp_similar<></code> is <code>mp_true</code>.</p>
4380 <div class="listingblock">
4381 <div class="title">Code Example 70. mp_similar</div>
4382 <div class="content">
4383 <pre class="highlight"><code>using R1 = mp_similar<void>; // mp_true
4384 using R2 = mp_similar<void, void>; // mp_true
4385 using R3 = mp_similar<void, void, void>; // mp_true
4386 using R4 = mp_similar<void, void, float>; // mp_false
4388 template<class T> struct X;
4389 template<class... T> struct Y;
4391 using R5 = mp_similar<X<int>, X<void>, X<float>>; // mp_true
4392 using R6 = mp_similar<Y<>, Y<void>, Y<void, void>>; // mp_true
4393 using R7 = mp_similar<X<void>, Y<void>>; // mp_false</code></pre>
4398 <h4 id="mp_plust">mp_plus<T…​></h4>
4399 <div class="literalblock">
4400 <div class="content">
4401 <pre>template<class... T> using mp_plus = /*...*/;</pre>
4404 <div class="paragraph">
4405 <p><code>mp_plus<T…​></code> is an integral constant type with a value that is the sum of <code>U::value</code> for all types <code>U</code> in <code>T…​</code>.
4406 <code>mp_plus<></code> is <code>mp_int<0></code>.</p>
4410 <h4 id="mp_lesst1_t2">mp_less<T1, T2></h4>
4411 <div class="literalblock">
4412 <div class="content">
4413 <pre>template<class T1, class T2> using mp_less = /*...*/;</pre>
4416 <div class="paragraph">
4417 <p><code>mp_less<T1, T2></code> is <code>mp_true</code> when the numeric value of <code>T1::value</code> is less than the numeric value of <code>T2::value</code>,
4418 <code>mp_false</code> otherwise.</p>
4420 <div class="paragraph">
4421 <p>(Note that this is not necessarily the same as <code>T1::value < T2::value</code> when comparing between signed and unsigned types;
4422 <code>-1 < 1u</code> is <code>false</code>, but <code>mp_less<mp_int<-1>, mp_size_t<1>></code> is <code>mp_true</code>.)</p>
4426 <h4 id="mp_mint1_t">mp_min<T1, T…​></h4>
4427 <div class="literalblock">
4428 <div class="content">
4429 <pre>template<class T1, class... T> using mp_min = mp_min_element<mp_list<T1, T...>, mp_less>;</pre>
4432 <div class="paragraph">
4433 <p><code>mp_min<T…​></code> returns the type <code>U</code> in <code>T…​</code> with the lowest <code>U::value</code>.</p>
4437 <h4 id="mp_maxt1_t">mp_max<T1, T…​></h4>
4438 <div class="literalblock">
4439 <div class="content">
4440 <pre>template<class T1, class... T> using mp_max = mp_max_element<mp_list<T1, T...>, mp_less>;</pre>
4443 <div class="paragraph">
4444 <p><code>mp_max<T…​></code> returns the type <code>U</code> in <code>T…​</code> with the highest <code>U::value</code>.</p>
4449 <h3 id="bind">Bind, <boost/mp11/bind.hpp></h3>
4451 <h4 id="mp_argi">mp_arg<I></h4>
4452 <div class="literalblock">
4453 <div class="content">
4454 <pre>template<std::size_t I> struct mp_arg;</pre>
4457 <div class="paragraph">
4458 <p><code>mp_arg<I></code> is a quoted metafunction whose nested template <code>fn<T…​></code> returns the <code>I</code>-th zero-based element of <code>T…​</code>.</p>
4462 <h4 id="1_9">_1, …​, _9</h4>
4463 <div class="literalblock">
4464 <div class="content">
4465 <pre>using _1 = mp_arg<0>;
4466 using _2 = mp_arg<1>;
4467 using _3 = mp_arg<2>;
4468 using _4 = mp_arg<3>;
4469 using _5 = mp_arg<4>;
4470 using _6 = mp_arg<5>;
4471 using _7 = mp_arg<6>;
4472 using _8 = mp_arg<7>;
4473 using _9 = mp_arg<8>;</pre>
4476 <div class="paragraph">
4477 <p><code>_1</code> to <code>_9</code> are placeholder types, the equivalent to the placeholders of <code>boost::bind</code>.</p>
4481 <h4 id="mp_bindf_t">mp_bind<F, T…​></h4>
4482 <div class="literalblock">
4483 <div class="content">
4484 <pre>template<template<class...> class F, class... T> struct mp_bind;</pre>
4487 <div class="paragraph">
4488 <p><code>mp_bind<F, T…​></code> is a quoted metafunction that implements the type-based
4489 equivalent of <code>boost::bind</code>. Its nested template <code>fn<U…​></code> returns <code>F<V…​></code>,
4490 where <code>V…​</code> is <code>T…​</code> with the placeholders replaced by the corresponding
4491 element of <code>U…​</code> and the <code>mp_bind</code>, <code>mp_bind_front</code>, and <code>mp_bind_back</code>
4492 expressions replaced with their corresponding evaluations against <code>U…​</code>.</p>
4494 <div class="paragraph">
4495 <p>For example, <code>mp_bind<F, int, _2, mp_bind<G, _1>>::fn<float, void></code> is <code>F<int, void, G<float>></code>.</p>
4499 <h4 id="mp_bind_qq_t">mp_bind_q<Q, T…​></h4>
4500 <div class="literalblock">
4501 <div class="content">
4502 <pre>template<class Q, class... T> using mp_bind_q = mp_bind<Q::template fn, T...>;</pre>
4505 <div class="paragraph">
4506 <p>As <code>mp_bind</code>, but takes a quoted metafunction.</p>
4510 <h4 id="mp_bind_frontf_t">mp_bind_front<F, T…​></h4>
4511 <div class="literalblock">
4512 <div class="content">
4513 <pre>template<template<class...> class F, class... T> struct mp_bind_front;</pre>
4516 <div class="paragraph">
4517 <p><code>mp_bind_front<F, T…​></code> binds the leftmost arguments of <code>F</code> to <code>T…​</code>. Its nested template <code>fn<U…​></code> returns <code>F<T…​, U…​></code>.</p>
4521 <h4 id="mp_bind_front_qq_t">mp_bind_front_q<Q, T…​></h4>
4522 <div class="literalblock">
4523 <div class="content">
4524 <pre>template<class Q, class... T> using mp_bind_front_q =
4525 mp_bind_front<Q::template fn, T...>;</pre>
4528 <div class="paragraph">
4529 <p>As <code>mp_bind_front</code>, but takes a quoted metafunction.</p>
4533 <h4 id="mp_bind_backf_t">mp_bind_back<F, T…​></h4>
4534 <div class="literalblock">
4535 <div class="content">
4536 <pre>template<template<class...> class F, class... T> struct mp_bind_back;</pre>
4539 <div class="paragraph">
4540 <p><code>mp_bind_back<F, T…​></code> binds the rightmost arguments of <code>F</code> to <code>T…​</code>. Its nested template <code>fn<U…​></code> returns <code>F<U…​, T…​></code>.</p>
4544 <h4 id="mp_bind_back_qq_t">mp_bind_back_q<Q, T…​></h4>
4545 <div class="literalblock">
4546 <div class="content">
4547 <pre>template<class Q, class... T> using mp_bind_back_q =
4548 mp_bind_back<Q::template fn, T...>;</pre>
4551 <div class="paragraph">
4552 <p>As <code>mp_bind_back</code>, but takes a quoted metafunction.</p>
4557 <h3 id="integer_sequence">Integer Sequences, <boost/mp11/integer_sequence.hpp></h3>
4559 <h4 id="integer_sequencet_i">integer_sequence<T, I…​></h4>
4560 <div class="literalblock">
4561 <div class="content">
4562 <pre>template<class T, T... I> struct integer_sequence
4567 <div class="paragraph">
4568 <p><code>integer_sequence<T, I…​></code> holds a sequence of integers of type <code>T</code>. Same as C++14’s <code>std::integer_sequence</code>.</p>
4572 <h4 id="make_integer_sequencet_n">make_integer_sequence<T, N></h4>
4573 <div class="literalblock">
4574 <div class="content">
4575 <pre>template<class T, T N> using make_integer_sequence = /*...*/;</pre>
4578 <div class="paragraph">
4579 <p><code>make_integer_sequence<T, N></code> is <code>integer_sequence<T, 0, 1, …​, N-1></code>. Same as C++14’s <code>std::make_integer_sequence</code>.</p>
4583 <h4 id="index_sequencei">index_sequence<I…​></h4>
4584 <div class="literalblock">
4585 <div class="content">
4586 <pre>template<std::size_t... I> using index_sequence = integer_sequence<std::size_t, I...>;</pre>
4589 <div class="paragraph">
4590 <p><code>index_sequence<I…​></code> is an alias for <code>integer_sequence<size_t, I…​></code>. Same as C++14’s <code>std::index_sequence</code>.</p>
4594 <h4 id="make_index_sequencen">make_index_sequence<N></h4>
4595 <div class="literalblock">
4596 <div class="content">
4597 <pre>template<std::size_t N> using make_index_sequence =
4598 make_integer_sequence<std::size_t, N>;</pre>
4601 <div class="paragraph">
4602 <p><code>make_index_sequence<N></code> is <code>index_sequence<0, 1, …​, N-1></code>. Same as C++14’s <code>std::make_index_sequence</code>.</p>
4606 <h4 id="index_sequence_fort">index_sequence_for<T…​></h4>
4607 <div class="literalblock">
4608 <div class="content">
4609 <pre>template<class... T> using index_sequence_for =
4610 make_integer_sequence<std::size_t, sizeof...(T)>;</pre>
4613 <div class="paragraph">
4614 <p><code>index_sequence_for<N></code> is <code>make_index_sequence<sizeof…​(T)></code>. Same as C++14’s <code>std::index_sequence_for</code>.</p>
4619 <h3 id="tuple">Tuple Operations, <boost/mp11/tuple.hpp></h3>
4621 <h4 id="tuple_applyf_tp">tuple_apply(f, tp)</h4>
4622 <div class="literalblock">
4623 <div class="content">
4624 <pre>template<class F, class Tp> constexpr /*...*/ tuple_apply(F&& f, Tp&& tp);</pre>
4627 <div class="paragraph">
4628 <p><code>tuple_apply(f, tp)</code> returns <code>std::forward<F>(f)(std::get<J>(std::forward<Tp>(tp))…​)</code> for <code>J</code> in 0..<code>N-1</code>,
4629 where <code>N</code> is <code>std::tuple_size<typename std::remove_reference<Tp>::type>::value</code>. Same as <code>std::apply</code> in C++17.</p>
4633 <h4 id="construct_from_tuplettp">construct_from_tuple<T>(tp)</h4>
4634 <div class="literalblock">
4635 <div class="content">
4636 <pre>template<class T, class Tp> T construct_from_tuple(Tp&& tp);</pre>
4639 <div class="paragraph">
4640 <p><code>construct_from_tuple<T>(tp)</code> returns <code>T(std::get<J>(std::forward<Tp>(tp))…​)</code> for <code>J</code> in 0..<code>N-1</code>,
4641 where <code>N</code> is <code>std::tuple_size<typename std::remove_reference<Tp>::type>::value</code>. Same as <code>std::make_from_tuple</code> in C++17.
4642 The name of the function doesn’t match the C++17 one to avoid ambiguities when both are visible or in unqualified calls.</p>
4646 <h4 id="tuple_for_eachtp_f">tuple_for_each(tp, f)</h4>
4647 <div class="literalblock">
4648 <div class="content">
4649 <pre>template<class Tp, class F> constexpr F tuple_for_each(Tp&& tp, F&& f);</pre>
4652 <div class="paragraph">
4653 <p><code>tuple_for_each(tp, f)</code> applies the function object <code>f</code> to each element of <code>tp</code> by evaluating the
4654 expression <code>f(std::get<J>(std::forward<Tp>(tp)))</code> for <code>J</code> in 0..<code>N-1</code>, where <code>N</code> is <code>std::tuple_size<typename std::remove_reference<Tp>::type>::value</code>.</p>
4656 <div class="paragraph">
4657 <p>Returns <code>std::forward<F>(f)</code>.</p>
4662 <h3 id="mp11">Convenience Header, <boost/mp11.hpp></h3>
4663 <div class="paragraph">
4664 <p>The convenience header <code><boost/mp11.hpp></code> includes all of the
4665 headers listed previously in this reference.</p>
4669 <h3 id="mpl">MPL Support, <boost/mp11/mpl.hpp></h3>
4670 <div class="paragraph">
4671 <p>The header <code><boost/mp11/mpl.hpp></code>, when included, defines the
4672 necessary support infrastructure for <code>mp_list</code> and <code>std::tuple</code>
4673 to be valid <a href="../../../../libs/mpl">MPL</a> sequences.</p>
4675 <div class="admonitionblock note">
4679 <div class="title">Note</div>
4681 <td class="content">
4682 <code>mpl.hpp</code> is not included by <code><boost/mp11.hpp></code>.
4687 <div class="paragraph">
4688 <p>It’s also possible to only enable support for <code>mp_list</code> by
4689 including <code><boost/mp11/mpl_list.hpp></code>, and for <code>std::tuple</code>
4690 by including <code><boost/mp11/mpl_tuple.hpp></code>. This may be required
4691 because some libraries, such as Boost.Fusion, contain their own MPL
4692 support for <code>std::tuple</code>, which conflicts with Mp11’s one.</p>
4698 <h2 id="copyright_license_and_acknowledgments">Appendix A: Copyright, License, and Acknowledgments</h2>
4699 <div class="sectionbody">
4700 <div class="paragraph">
4701 <p>This documentation is</p>
4706 <p>Copyright 2017-2019 Peter Dimov</p>
4709 <p>Copyright 2017 Bjørn Reese</p>
4713 <div class="paragraph">
4714 <p>and is distributed under the <a href="http://www.boost.org/LICENSE_1_0.txt">Boost Software License, Version 1.0</a>.</p>
4716 <div class="paragraph">
4717 <p>The "Simple C++11 metaprogramming" articles have been graciously converted to Asciidoc format for incorporation
4718 into this documentation by Glen Fernandes.</p>
4724 <div id="footer-text">
4725 Last updated 2019-12-10 00:19:27 UTC
4730 *:not(pre)>code { background: none; color: #600000; }
4731 :not(pre):not([class^=L])>code { background: none; color: #600000; }
4732 table tr.even, table tr.alt, table tr:nth-of-type(even) { background: none; }