[libsigc++2/variadic_bind4] bind(): Add a static_assert() for when bind<num> is passed a too-high index.



commit c5e3e60cad44f58e9bc851259b4710033404b90e
Author: Murray Cumming <murrayc murrayc com>
Date:   Wed Mar 2 22:21:18 2016 +0100

    bind(): Add a static_assert() for when bind<num> is passed a too-high index.

 sigc++/adaptors/bind.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/sigc++/adaptors/bind.h b/sigc++/adaptors/bind.h
index 3a39647..0668da7 100644
--- a/sigc++/adaptors/bind.h
+++ b/sigc++/adaptors/bind.h
@@ -136,6 +136,10 @@ struct bind_functor : public adapts<T_functor>
       auto t_args = std::tuple<T_arg...>(std::forward<T_arg>(_A_arg)...);
       constexpr auto t_args_size = std::tuple_size<tuple_type_args>::value;
       
+      //Prevent calling tuple_start<> with values that will cause a compilation error.
+      static_assert(I_location < t_args_size,
+        "I_location must be less than the number of arguments.");
+
       auto t_start = internal::tuple_start<I_location>(t_args);
       auto t_bound = internal::tuple_transform_each<internal::TransformEachInvoker>(bound_);
       auto t_end = internal::tuple_end<t_args_size - I_location>(t_args);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]