summaryrefslogtreecommitdiff
path: root/libs/type_traits/test/has_postfix_operators.hpp
diff options
context:
space:
mode:
authorAnas Nashif <anas.nashif@intel.com>2012-10-30 12:57:26 -0700
committerAnas Nashif <anas.nashif@intel.com>2012-10-30 12:57:26 -0700
commit1a78a62555be32868418fe52f8e330c9d0f95d5a (patch)
treed3765a80e7d3b9640ec2e930743630cd6b9fce2b /libs/type_traits/test/has_postfix_operators.hpp
downloadboost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.gz
boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.tar.bz2
boost-1a78a62555be32868418fe52f8e330c9d0f95d5a.zip
Imported Upstream version 1.49.0upstream/1.49.0
Diffstat (limited to 'libs/type_traits/test/has_postfix_operators.hpp')
-rw-r--r--libs/type_traits/test/has_postfix_operators.hpp131
1 files changed, 131 insertions, 0 deletions
diff --git a/libs/type_traits/test/has_postfix_operators.hpp b/libs/type_traits/test/has_postfix_operators.hpp
new file mode 100644
index 0000000000..3348ca5515
--- /dev/null
+++ b/libs/type_traits/test/has_postfix_operators.hpp
@@ -0,0 +1,131 @@
+// (C) Copyright Frederic Bron 2009-2011.
+// Use, modification and distribution are subject to 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)
+
+#ifndef TT_HAS_POSTFIX_OPERATORS_HPP
+#define TT_HAS_POSTFIX_OPERATORS_HPP
+
+// test with one template parameter
+#define TEST_T(TYPE,RESULT) BOOST_CHECK_INTEGRAL_CONSTANT((::boost::BOOST_TT_TRAIT_NAME<TYPE>::value), RESULT)
+// test with one template parameter plus return value
+#define TEST_TR(TYPE,RET,RESULT) BOOST_CHECK_INTEGRAL_CONSTANT((::boost::BOOST_TT_TRAIT_NAME<TYPE,RET>::value), RESULT)
+
+namespace {
+
+struct without { };
+
+struct ret { };
+
+struct internal { ret operator BOOST_TT_TRAIT_OP (int) const; };
+
+struct external { };
+ret operator BOOST_TT_TRAIT_OP (const external&, int);
+
+struct comma1_ret { };
+struct ret_with_comma1 { comma1_ret operator,(int); };
+
+struct internal_comma1 { ret_with_comma1 operator BOOST_TT_TRAIT_OP (int) const; };
+
+struct external_comma1 { };
+ret_with_comma1 operator BOOST_TT_TRAIT_OP (const external_comma1&, int);
+
+struct ret_with_comma2 { void operator,(int); };
+
+struct internal_comma2 { ret_with_comma2 operator BOOST_TT_TRAIT_OP (int) const; };
+
+struct external_comma2 { };
+ret_with_comma2 operator BOOST_TT_TRAIT_OP (const external_comma2&, int);
+
+struct returns_int { int operator BOOST_TT_TRAIT_OP (int); };
+
+struct returns_void { void operator BOOST_TT_TRAIT_OP (int); };
+
+struct returns_void_star { void *operator BOOST_TT_TRAIT_OP (int); };
+
+struct returns_double { double operator BOOST_TT_TRAIT_OP (int); };
+
+struct ret1 { };
+struct convertible_to_ret1 { operator ret1 () const; };
+struct returns_convertible_to_ret1 { convertible_to_ret1 operator BOOST_TT_TRAIT_OP (int); };
+
+struct convertible_to_ret2 { };
+struct ret2 { ret2(const convertible_to_ret2); };
+struct returns_convertible_to_ret2 { convertible_to_ret2 operator BOOST_TT_TRAIT_OP (int); };
+
+class Base1 { };
+class Derived1 : public Base1 { };
+
+bool operator BOOST_TT_TRAIT_OP (const Base1&, int) { return true; }
+
+class Base2 { };
+struct Derived2 : public Base2 {
+ Derived2(int); // to check if it works with a class that is not default constructible
+};
+
+bool operator BOOST_TT_TRAIT_OP (const Derived2&, int) { return true; }
+
+struct tag { };
+
+//class internal_private { ret operator BOOST_TT_TRAIT_OP (int) const; };
+
+void common() {
+ TEST_T(void, false);
+ TEST_TR(void, void, false);
+ TEST_TR(void, int, false);
+
+ TEST_T(without, false);
+ TEST_T(internal, true);
+ TEST_T(external, true);
+ TEST_T(internal_comma1, true);
+ TEST_T(external_comma1, true);
+ TEST_T(internal_comma2, true);
+ TEST_T(external_comma2, true);
+ TEST_T(returns_int, true);
+ TEST_T(returns_void, true);
+ TEST_T(returns_void_star, true);
+ TEST_T(returns_double, true);
+ TEST_T(returns_convertible_to_ret1, true);
+ TEST_T(returns_convertible_to_ret2, true);
+ TEST_T(Base1, true);
+ TEST_T(Derived1, true);
+ TEST_T(Base2, false);
+ TEST_T(Derived2, true);
+
+ TEST_TR(without, void, false);
+ TEST_TR(without, bool, false);
+ TEST_TR(internal, void, false);
+ TEST_TR(internal, bool, false);
+ TEST_TR(internal, ret, true);
+ TEST_TR(internal_comma1, void, false);
+ TEST_TR(internal_comma1, bool, false);
+ TEST_TR(internal_comma1, ret_with_comma1, true);
+ TEST_TR(internal_comma2, void, false);
+ TEST_TR(internal_comma2, bool, false);
+ TEST_TR(internal_comma2, ret_with_comma2, true);
+ TEST_TR(external, void, false);
+ TEST_TR(external, bool, false);
+ TEST_TR(external, ret, true);
+ TEST_TR(returns_int, void, false);
+ TEST_TR(returns_int, bool, true);
+ TEST_TR(returns_int, int, true);
+ TEST_TR(returns_void, void, true);
+ TEST_TR(returns_void, bool, false);
+ TEST_TR(returns_void_star, bool, true);
+ TEST_TR(returns_double, void, false);
+ TEST_TR(returns_double, bool, true);
+ TEST_TR(returns_double, double, true);
+ TEST_TR(returns_convertible_to_ret1, void, false);
+ TEST_TR(returns_convertible_to_ret1, ret1, true);
+ TEST_TR(returns_convertible_to_ret2, ret2, true);
+ TEST_TR(Base1, bool, true);
+ TEST_TR(Derived1, bool, true);
+ TEST_TR(Base2, bool, false);
+ TEST_TR(Derived2, bool, true);
+// compile time error
+// TEST_T(internal_private, false);
+}
+
+}
+
+#endif