From 3bd2a9c00d6ab4fb6020d4f62fc4b4b5e81d991e Mon Sep 17 00:00:00 2001 From: Jason Turner Date: Wed, 10 Sep 2014 07:40:16 -0600 Subject: [PATCH] Clean up bind_first implementation --- include/chaiscript/dispatchkit/bind_first.hpp | 71 +------------------ 1 file changed, 3 insertions(+), 68 deletions(-) diff --git a/include/chaiscript/dispatchkit/bind_first.hpp b/include/chaiscript/dispatchkit/bind_first.hpp index 16f95b06..6030e98a 100644 --- a/include/chaiscript/dispatchkit/bind_first.hpp +++ b/include/chaiscript/dispatchkit/bind_first.hpp @@ -13,80 +13,15 @@ namespace chaiscript { namespace detail { - - template - struct Placeholder - { - }; - - template<> - struct Placeholder<1> - { - static decltype(std::placeholders::_1) value() { return std::placeholders::_1; } - }; - - template<> - struct Placeholder<2> - { - static decltype(std::placeholders::_2) value() { return std::placeholders::_2; } - }; - - template<> - struct Placeholder<3> - { - static decltype(std::placeholders::_3) value() { return std::placeholders::_3; } - }; - - template<> - struct Placeholder<4> - { - static decltype(std::placeholders::_4) value() { return std::placeholders::_4; } - }; - - template<> - struct Placeholder<5> - { - static decltype(std::placeholders::_5) value() { return std::placeholders::_5; } - }; - - template<> - struct Placeholder<6> - { - static decltype(std::placeholders::_6) value() { return std::placeholders::_6; } - }; - - template<> - struct Placeholder<7> - { - static decltype(std::placeholders::_7) value() { return std::placeholders::_7; } - }; - - template<> - struct Placeholder<8> - { - static decltype(std::placeholders::_8) value() { return std::placeholders::_8; } - }; - - template<> - struct Placeholder<9> - { - static decltype(std::placeholders::_9) value() { return std::placeholders::_9; } - }; - - template<> - struct Placeholder<10> - { - static decltype(std::placeholders::_10) value() { return std::placeholders::_10; } - }; - - template struct Bind_First { template static std::function bind(F f, InnerParams ... innerparams) { - return Bind_First::bind(f, innerparams..., Placeholder::value()); + static auto placeholder = std::make_tuple(std::placeholders::_1,std::placeholders::_2,std::placeholders::_3,std::placeholders::_4,std::placeholders::_5,std::placeholders::_6,std::placeholders::_7,std::placeholders::_8,std::placeholders::_9,std::placeholders::_10); + + return Bind_First::bind(f, innerparams..., std::get(placeholder)); } };