framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
variadic_switch_return.hpp
Go to the documentation of this file.
1 // Copyright (C) 2012 iwg molw5
2 // For conditions of distribution and use, see copyright notice in COPYING
3 
17 #pragma once
18 
19 #ifdef FRAMEWORK_NO_BOOST
20  #error "Not implemented"
21 #endif
22 
23 #include <utility>
24 
25 #include <boost/preprocessor/config/limits.hpp>
26 #include <boost/preprocessor/repetition/repeat.hpp>
27 #include <boost/preprocessor/punctuation/comma_if.hpp>
28 #include <boost/preprocessor/iteration/local.hpp>
29 
32 
33 #ifndef FRAMEWORK_VARIADIC_SWITCH_LIMIT
34  #define FRAMEWORK_VARIADIC_SWITCH_LIMIT 20
35 #else
36  #if FRAMEWORK_VARIADIC_SWITCH_LIMIT > BOOST_PP_LIMIT_REPEAT
37  #error "Variadic switch limit cannot exceed BOOST_PP_LIMIT_REPEAT"
38  #endif
39 #endif
40 
41 #if FRAMEWORK_VARIADIC_SWITCH_LIMIT <= 0
42  #error "Invalid variadic switch limit"
43 #endif
44 
45 namespace framework
46 {
47  namespace detail
48  {
49  template <typename CaseList>
50  struct variadic_switch_return_impl;
51  }
52 
94  template <
95  typename CaseList,
96  typename Handler,
97  typename Index,
98  typename... Args>
100  auto variadic_switch_return (Handler&& handler, Index&& index, Args&&... args) ->
101  decltype(handler(std::forward <Args> (args)...))
102  {
103  return detail::variadic_switch_return_impl <CaseList>::run(
104  std::forward <Handler> (handler),
105  std::forward <Index> (index),
106  std::forward <Args> (args)...);
107  }
108 }
109 
110 #include <framework/common/variadic_switch_return.inl>