summaryrefslogtreecommitdiffstats
path: root/src/boost/libs/hof/test/fail
diff options
context:
space:
mode:
Diffstat (limited to 'src/boost/libs/hof/test/fail')
-rw-r--r--src/boost/libs/hof/test/fail/always.cpp14
-rw-r--r--src/boost/libs/hof/test/fail/apply_eval.cpp11
-rw-r--r--src/boost/libs/hof/test/fail/flip_lazy.cpp14
-rw-r--r--src/boost/libs/hof/test/fail/implicit.cpp29
-rw-r--r--src/boost/libs/hof/test/fail/rotate_lazy.cpp14
-rw-r--r--src/boost/libs/hof/test/fail/unpack.cpp27
-rw-r--r--src/boost/libs/hof/test/fail/unpack_uncallable.cpp24
7 files changed, 133 insertions, 0 deletions
diff --git a/src/boost/libs/hof/test/fail/always.cpp b/src/boost/libs/hof/test/fail/always.cpp
new file mode 100644
index 00000000..76b6e5d7
--- /dev/null
+++ b/src/boost/libs/hof/test/fail/always.cpp
@@ -0,0 +1,14 @@
+/*=============================================================================
+ Copyright (c) 2017 Paul Fultz II
+ always.cpp
+ 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 <boost/hof/always.hpp>
+#include <memory>
+
+int main() {
+ auto f = boost::hof::always(std::unique_ptr<int>{new int(1)});
+ auto i = f(1, 2, 3);
+ (void)i;
+}
diff --git a/src/boost/libs/hof/test/fail/apply_eval.cpp b/src/boost/libs/hof/test/fail/apply_eval.cpp
new file mode 100644
index 00000000..c87d7ed9
--- /dev/null
+++ b/src/boost/libs/hof/test/fail/apply_eval.cpp
@@ -0,0 +1,11 @@
+/*=============================================================================
+ Copyright (c) 2017 Paul Fultz II
+ apply_eval.cpp
+ 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 <boost/hof/apply_eval.hpp>
+
+int main() {
+ (void)boost::hof::apply_eval(boost::hof::always(), 1, 2);
+}
diff --git a/src/boost/libs/hof/test/fail/flip_lazy.cpp b/src/boost/libs/hof/test/fail/flip_lazy.cpp
new file mode 100644
index 00000000..7d5e0dc3
--- /dev/null
+++ b/src/boost/libs/hof/test/fail/flip_lazy.cpp
@@ -0,0 +1,14 @@
+/*=============================================================================
+ Copyright (c) 2017 Paul Fultz II
+ flip_lazy.cpp
+ 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 <boost/hof/lazy.hpp>
+#include <boost/hof/placeholders.hpp>
+#include <boost/hof/flip.hpp>
+
+int main() {
+ auto i = (boost::hof::flip(boost::hof::_1 - boost::hof::_2) * boost::hof::_1)(3, 6);
+ (void)i;
+}
diff --git a/src/boost/libs/hof/test/fail/implicit.cpp b/src/boost/libs/hof/test/fail/implicit.cpp
new file mode 100644
index 00000000..df81297a
--- /dev/null
+++ b/src/boost/libs/hof/test/fail/implicit.cpp
@@ -0,0 +1,29 @@
+/*=============================================================================
+ Copyright (c) 2017 Paul Fultz II
+ implicit.cpp
+ 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 <boost/hof/implicit.hpp>
+
+template<class T>
+struct auto_caster
+{
+ template<class U>
+ T operator()(U x)
+ {
+ return T(x);
+ }
+};
+
+
+int main()
+{
+ boost::hof::implicit<auto_caster> auto_cast = {};
+ auto x = auto_cast(1.5);
+ (void)x;
+// This is not possible in c++17 due to guaranteed copy elison
+#if BOOST_HOF_HAS_STD_17 || (defined(__GNUC__) && !defined (__clang__) && __GNUC__ == 4 && __GNUC_MINOR__ < 7)
+ static_assert(false, "Always fail");
+#endif
+}
diff --git a/src/boost/libs/hof/test/fail/rotate_lazy.cpp b/src/boost/libs/hof/test/fail/rotate_lazy.cpp
new file mode 100644
index 00000000..59c4f4e9
--- /dev/null
+++ b/src/boost/libs/hof/test/fail/rotate_lazy.cpp
@@ -0,0 +1,14 @@
+/*=============================================================================
+ Copyright (c) 2017 Paul Fultz II
+ rotate_lazy.cpp
+ 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 <boost/hof/lazy.hpp>
+#include <boost/hof/placeholders.hpp>
+#include <boost/hof/rotate.hpp>
+
+int main() {
+ auto i = (boost::hof::rotate(boost::hof::_1 - boost::hof::_2) * boost::hof::_1)(3, 6);
+ (void)i;
+}
diff --git a/src/boost/libs/hof/test/fail/unpack.cpp b/src/boost/libs/hof/test/fail/unpack.cpp
new file mode 100644
index 00000000..f4758be0
--- /dev/null
+++ b/src/boost/libs/hof/test/fail/unpack.cpp
@@ -0,0 +1,27 @@
+/*=============================================================================
+ Copyright (c) 2017 Paul Fultz II
+ unpack.cpp
+ 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 <boost/hof/unpack.hpp>
+
+struct foo
+{};
+
+namespace boost { namespace hof {
+
+template<>
+struct unpack_sequence<foo>
+{
+ template<class F, class S>
+ constexpr static int apply(F&&, S&&)
+ {
+ return 0;
+ }
+};
+}
+
+int main() {
+ boost::hof::unpack(boost::hof::always(1))(foo{});
+}
diff --git a/src/boost/libs/hof/test/fail/unpack_uncallable.cpp b/src/boost/libs/hof/test/fail/unpack_uncallable.cpp
new file mode 100644
index 00000000..d3c946f4
--- /dev/null
+++ b/src/boost/libs/hof/test/fail/unpack_uncallable.cpp
@@ -0,0 +1,24 @@
+/*=============================================================================
+ Copyright (c) 2017 Paul Fultz II
+ unpack_uncallable.cpp
+ 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 <boost/hof/unpack.hpp>
+
+struct foo
+{};
+
+namespace boost { namespace hof {
+
+template<>
+struct unpack_sequence<foo>
+{
+ template<class F, class S>
+ constexpr static auto apply(F&&, S&& s) BOOST_HOF_RETURNS(s.bar);
+};
+}
+
+int main() {
+ boost::hof::unpack(boost::hof::always(1))(foo{});
+}