]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/boost/libs/spirit/test/x3/container_support.cpp
import quincy beta 17.1.0
[ceph.git] / ceph / src / boost / libs / spirit / test / x3 / container_support.cpp
index f8c79f1ddc4b5b36fcbf575dcae34315b800d30d..809d6ac3bc5a833628627641c0b7d4a0493a3c41 100644 (file)
 
 namespace x3 = boost::spirit::x3;
 
+
+// check if we did not break user defined specializations
+namespace check_substitute {
+template <typename T> struct foo {};
+template <typename T> struct bar { using type = T; };
+template <typename T> struct is_bar : std::false_type {};
+template <typename T> struct is_bar<bar<T>> : std::true_type {};
+}
+
+namespace boost { namespace spirit { namespace x3 { namespace traits {
+using namespace check_substitute;
+
+template <typename T, typename U>
+struct is_substitute<foo<T>, foo<U>> : is_substitute<T, U> {};
+
+template <typename T, typename U>
+struct is_substitute<T, U, std::enable_if_t<is_bar<T>::value && is_bar<U>::value>>
+  : is_substitute<typename T::type, typename U::type> {};
+}}}}
+
+namespace check_substitute {
+using x3::traits::is_substitute;
+static_assert(is_substitute<foo<int>, foo<int>>::value, "is_substitute problem");
+static_assert(!is_substitute<foo<int>, foo<long>>::value, "is_substitute problem");
+static_assert(is_substitute<bar<int>, bar<int>>::value, "is_substitute problem");
+static_assert(!is_substitute<bar<int>, bar<long>>::value, "is_substitute problem");
+}
+
+
 x3::rule<class pair_rule, std::pair<std::string,std::string>> const pair_rule("pair");
 x3::rule<class string_rule, std::string> const string_rule("string");
 
@@ -180,25 +209,6 @@ int
 main()
 {
     using x3::traits::is_associative;
-    using x3::traits::is_reservable;
-
-    static_assert(is_reservable<std::vector<int>>::value, "is_reservable problem");
-    static_assert(is_reservable<std::string>::value, "is_reservable problem");
-    static_assert(is_reservable<std::unordered_set<int>>::value, "is_reservable problem");
-    static_assert(is_reservable<boost::unordered_set<int>>::value, "is_reservable problem");
-    static_assert(is_reservable<std::unordered_multiset<int>>::value, "is_reservable problem");
-    static_assert(is_reservable<boost::unordered_multiset<int>>::value, "is_reservable problem");
-    static_assert(is_reservable<std::unordered_map<int,int>>::value, "is_reservable problem");
-    static_assert(is_reservable<boost::unordered_map<int,int>>::value, "is_reservable problem");
-    static_assert(is_reservable<std::unordered_multimap<int,int>>::value, "is_reservable problem");
-    static_assert(is_reservable<boost::unordered_multimap<int,int>>::value, "is_reservable problem");
-
-    static_assert(!is_reservable<std::deque<int>>::value, "is_reservable problem");
-    static_assert(!is_reservable<std::list<int>>::value, "is_reservable problem");
-    static_assert(!is_reservable<std::set<int>>::value, "is_reservable problem");
-    static_assert(!is_reservable<std::multiset<int>>::value, "is_reservable problem");
-    static_assert(!is_reservable<std::map<int,int>>::value, "is_reservable problem");
-    static_assert(!is_reservable<std::multimap<int,int>>::value, "is_reservable problem");
 
     // ------------------------------------------------------------------