From 27d0d547ee4d0cb83b678b176c8e96cb78de19b5 Mon Sep 17 00:00:00 2001
From: Peter Dimov
Date: Mon, 17 Jul 2017 19:28:36 +0300
Subject: [PATCH] Add mp_is_set
---
doc/html/mp11.html | 53 ++++++++++++++++++---------
doc/mp11/set.adoc | 6 ++++
include/boost/mp11/set.hpp | 19 ++++++++++
test/Jamfile | 1 +
test/mp_is_set.cpp | 73 ++++++++++++++++++++++++++++++++++++++
5 files changed, 135 insertions(+), 17 deletions(-)
create mode 100644 test/mp_is_set.cpp
diff --git a/doc/html/mp11.html b/doc/html/mp11.html
index 90b7f4b..09a461d 100644
--- a/doc/html/mp11.html
+++ b/doc/html/mp11.html
@@ -4,7 +4,7 @@
-
+
Boost.Mp11: A C++11 metaprogramming library
@@ -90,13 +90,12 @@ strong,b{font-weight:bold;line-height:inherit}
small{font-size:60%;line-height:inherit}
code{font-family:"Droid Sans Mono","DejaVu Sans Mono",monospace;font-weight:400;color:rgba(0,0,0,.9)}
ul,ol,dl{font-size:1em;line-height:1.6;margin-bottom:1.25em;list-style-position:outside;font-family:inherit}
-ul,ol,ul.no-bullet,ol.no-bullet{margin-left:1.5em}
+ul,ol{margin-left:1.5em}
ul li ul,ul li ol{margin-left:1.25em;margin-bottom:0;font-size:1em}
ul.square li ul,ul.circle li ul,ul.disc li ul{list-style:inherit}
ul.square{list-style-type:square}
ul.circle{list-style-type:circle}
ul.disc{list-style-type:disc}
-ul.no-bullet{list-style:none}
ol li ul,ol li ol{margin-left:1.25em;margin-bottom:0}
dl dt{margin-bottom:.3125em;font-weight:bold}
dl dd{margin-bottom:1.25em}
@@ -132,7 +131,11 @@ strong strong{font-weight:400}
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}
.keyseq kbd:first-child{margin-left:0}
.keyseq kbd:last-child{margin-right:0}
-.menuseq,.menu{color:rgba(0,0,0,.8)}
+.menuseq,.menuref{color:#000}
+.menuseq b:not(.caret),.menuref{font-weight:inherit}
+.menuseq{word-spacing:-.02em}
+.menuseq b.caret{font-size:1.25em;line-height:.8}
+.menuseq i.caret{font-weight:bold;text-align:center;width:.45em}
b.button:before,b.button:after{position:relative;top:-1px;font-weight:400}
b.button:before{content:"[";padding:0 3px 0 2px}
b.button:after{content:"]";padding:0 2px 0 3px}
@@ -199,7 +202,7 @@ table.tableblock>caption.title{white-space:nowrap;overflow:visible;max-width:0}
table.tableblock #preamble>.sectionbody>.paragraph:first-of-type p{font-size:inherit}
.admonitionblock>table{border-collapse:separate;border:0;background:none;width:100%}
.admonitionblock>table td.icon{text-align:center;width:80px}
-.admonitionblock>table td.icon img{max-width:none}
+.admonitionblock>table td.icon img{max-width:initial}
.admonitionblock>table td.icon .title{font-weight:bold;font-family:"Open Sans","DejaVu Sans",sans-serif;text-transform:uppercase}
.admonitionblock>table td.content{padding-left:1.125em;padding-right:1.25em;border-left:1px solid #ddddd8;color:rgba(0,0,0,.6)}
.admonitionblock>table td.content>:last-child>:last-child{margin-bottom:0}
@@ -255,13 +258,13 @@ table.pyhltable .linenodiv{background:none!important;padding-right:0!important}
table.tableblock{max-width:100%;border-collapse:separate}
table.tableblock td>.paragraph:last-child p>p:last-child,table.tableblock th>p:last-child,table.tableblock td>p:last-child{margin-bottom:0}
table.tableblock,th.tableblock,td.tableblock{border:0 solid #dedede}
-table.grid-all th.tableblock,table.grid-all td.tableblock{border-width:0 1px 1px 0}
-table.grid-all tfoot>tr>th.tableblock,table.grid-all tfoot>tr>td.tableblock{border-width:1px 1px 0 0}
-table.grid-cols th.tableblock,table.grid-cols td.tableblock{border-width:0 1px 0 0}
-table.grid-all *>tr>.tableblock:last-child,table.grid-cols *>tr>.tableblock:last-child{border-right-width:0}
-table.grid-rows th.tableblock,table.grid-rows td.tableblock{border-width:0 0 1px 0}
-table.grid-all tbody>tr:last-child>th.tableblock,table.grid-all tbody>tr:last-child>td.tableblock,table.grid-all thead:last-child>tr>th.tableblock,table.grid-rows tbody>tr:last-child>th.tableblock,table.grid-rows tbody>tr:last-child>td.tableblock,table.grid-rows thead:last-child>tr>th.tableblock{border-bottom-width:0}
-table.grid-rows tfoot>tr>th.tableblock,table.grid-rows tfoot>tr>td.tableblock{border-width:1px 0 0 0}
+table.grid-all>thead>tr>.tableblock,table.grid-all>tbody>tr>.tableblock{border-width:0 1px 1px 0}
+table.grid-all>tfoot>tr>.tableblock{border-width:1px 1px 0 0}
+table.grid-cols>*>tr>.tableblock{border-width:0 1px 0 0}
+table.grid-rows>thead>tr>.tableblock,table.grid-rows>tbody>tr>.tableblock{border-width:0 0 1px 0}
+table.grid-rows>tfoot>tr>.tableblock{border-width:1px 0 0 0}
+table.grid-all>*>tr>.tableblock:last-child,table.grid-cols>*>tr>.tableblock:last-child{border-right-width:0}
+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}
table.frame-all{border-width:1px}
table.frame-sides{border-width:0 1px}
table.frame-topbot{border-width:1px 0}
@@ -282,10 +285,12 @@ ul li ol{margin-left:1.5em}
dl dd{margin-left:1.125em}
dl dd:last-child,dl dd:last-child>:last-child{margin-bottom:0}
ol>li p,ul>li p,ul dd,ol dd,.olist .olist,.ulist .ulist,.ulist .olist,.olist .ulist{margin-bottom:.625em}
-ul.unstyled,ol.unnumbered,ul.checklist,ul.none{list-style-type:none}
-ul.unstyled,ol.unnumbered,ul.checklist{margin-left:.625em}
-ul.checklist li>p:first-child>.fa-square-o:first-child,ul.checklist li>p:first-child>.fa-check-square-o:first-child{width:1em;font-size:.85em}
-ul.checklist li>p:first-child>input[type="checkbox"]:first-child{width:1em;position:relative;top:1px}
+ul.checklist,ul.none,ol.none,ul.no-bullet,ol.no-bullet,ol.unnumbered,ul.unstyled,ol.unstyled{list-style-type:none}
+ul.no-bullet,ol.no-bullet,ol.unnumbered{margin-left:.625em}
+ul.unstyled,ol.unstyled{margin-left:0}
+ul.checklist{margin-left:.625em}
+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}
+ul.checklist li>p:first-child>input[type="checkbox"]:first-child{margin-right:.25em}
ul.inline{margin:0 auto .625em auto;margin-left:-1.375em;margin-right:0;padding:0;list-style:none;overflow:hidden}
ul.inline>li{list-style:none;float:left;margin-left:1.375em;display:block}
ul.inline>li>*{display:block}
@@ -302,7 +307,8 @@ ol.lowergreek{list-style-type:lower-greek}
td.hdlist1,td.hdlist2{vertical-align:top;padding:0 .625em}
td.hdlist1{font-weight:bold;padding-bottom:1.25em}
.literalblock+.colist,.listingblock+.colist{margin-top:-.5em}
-.colist>table tr>td:first-of-type{padding:0 .75em;line-height:1}
+.colist>table tr>td:first-of-type{padding:.4em .75em 0 .75em;line-height:1;vertical-align:top}
+.colist>table tr>td:first-of-type img{max-width:initial}
.colist>table tr>td:last-of-type{padding:.25em 0}
.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}
.imageblock.left,.imageblock[style*="float: left"]{margin:.25em .625em 1.25em 0}
@@ -365,6 +371,7 @@ div.unbreakable{page-break-inside:avoid}
.yellow{color:#bfbf00}
.yellow-background{background-color:#fafa00}
span.icon>.fa{cursor:default}
+a span.icon>.fa{cursor:inherit}
.admonitionblock td.icon [class^="fa icon-"]{font-size:2.5em;text-shadow:1px 1px 2px rgba(0,0,0,.5);cursor:default}
.admonitionblock td.icon .icon-note:before{content:"\f05a";color:#19407c}
.admonitionblock td.icon .icon-tip:before{content:"\f0eb";text-shadow:1px 1px 2px rgba(155,155,0,.8);color:#111}
@@ -543,6 +550,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
Set Operations, <boost/mp11/set.hpp>
A set is a list whose elements are unique.
+
mp_is_set<S>
+
+
+
template<class S> using mp_is_set = /*...*/;
+
+
+
+
mp_is_set<S>
is mp_true
if S
is a set, mp_false
otherwise.
+
+
+
mp_set_contains<S, V>
diff --git a/doc/mp11/set.adoc b/doc/mp11/set.adoc
index e8d708f..d57ec73 100644
--- a/doc/mp11/set.adoc
+++ b/doc/mp11/set.adoc
@@ -15,6 +15,12 @@ http://www.boost.org/LICENSE_1_0.txt
A set is a list whose elements are unique.
+## mp_is_set
+
+ template using mp_is_set = /*...*/;
+
+`mp_is_set` is `mp_true` if `S` is a set, `mp_false` otherwise.
+
## mp_set_contains
template using mp_set_contains = /*...*/;
diff --git a/include/boost/mp11/set.hpp b/include/boost/mp11/set.hpp
index a3b3b38..cd77d64 100644
--- a/include/boost/mp11/set.hpp
+++ b/include/boost/mp11/set.hpp
@@ -9,6 +9,7 @@
// http://www.boost.org/LICENSE_1_0.txt
#include
+#include
#include
namespace boost
@@ -78,6 +79,24 @@ template class L, class... U, class T1, class... T> struct mp
template using mp_set_push_front = typename detail::mp_set_push_front_impl::type;
+// mp_is_set
+namespace detail
+{
+
+template struct mp_is_set_impl
+{
+ using type = mp_false;
+};
+
+template class L, class... T> struct mp_is_set_impl>
+{
+ using type = mp_to_bool, mp_set_push_back, T...>>>;
+};
+
+} // namespace detail
+
+template using mp_is_set = typename detail::mp_is_set_impl::type;
+
} // namespace mp11
} // namespace boost
diff --git a/test/Jamfile b/test/Jamfile
index 05eefac..3396702 100644
--- a/test/Jamfile
+++ b/test/Jamfile
@@ -106,6 +106,7 @@ compile construct_from_tuple_cx.cpp : $(REQ) ;
run mp_set_contains.cpp : : : $(REQ) ;
run mp_set_push_back.cpp : : : $(REQ) ;
run mp_set_push_front.cpp : : : $(REQ) ;
+run mp_is_set.cpp : : : $(REQ) ;
# function
run mp_all.cpp : : : $(REQ) ;
diff --git a/test/mp_is_set.cpp b/test/mp_is_set.cpp
new file mode 100644
index 0000000..8657dc4
--- /dev/null
+++ b/test/mp_is_set.cpp
@@ -0,0 +1,73 @@
+
+// Copyright 2017 Peter Dimov.
+//
+// Distributed under the Boost Software License, Version 1.0.
+//
+// See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt
+
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+int main()
+{
+ using boost::mp11::mp_list;
+ using boost::mp11::mp_is_set;
+ using boost::mp11::mp_true;
+ using boost::mp11::mp_false;
+
+ {
+ BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same, mp_false>));
+ }
+
+ {
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ }
+
+ {
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ }
+
+ {
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_true>));
+ BOOST_TEST_TRAIT_TRUE((std::is_same>, mp_false>));
+ }
+
+ return boost::report_errors();
+}