It can be done and to prove it I have prepared the almost standard conforming implementation of bind function in C++11 (tested on clang 3.2 and gcc 4.8.1) that supports customizable group placeholders. The thinks that are missing are:
1. bind<R> - because its add nothing and implementation would be trivial
2. volatile, const volatile overloads of bind invoke operator - this is cause by lack of std::get overload for tuples which such qualification (const is supported).
3. _from<N> is not variable template (not supported)
The implementation can be found on:
https://github.com/tomaszkam/proposals/tree/master/bind.
Firstly the test cases can be found in
test.cpp. That test includes varidatic template cases and also covers combination of group and non group placeholders.
Firstly the new placeholders traits are placed in the file
placeholder_traits.hpp. I decided to include new is_placeholder that forwards to std::is_placeholder traits to be sure that new group placeholders won't work with std::bind. You may also see default implementation of placeholder_positions that provides backward compatibility with single argument placeholders definied using only std::is_placeholder. To mark bind expression the std::is_bind_expression is used.
The implementation of bind expression is placed in file
bind.hpp. This implementation has no hardcoded placeholders types and depends only on placeholder traits.
The definition of actual grouping placeholders can be found at
placeholders.hpp. The _from<N> is at this point alias template but should be changed to variable template in future.
Are there any interest in defining group placeholders for the bind? If so I think the ability to define custom group placeholders by the user is must have, to avoid exponential grow of bind implementation. In the proposed approach implementation of _group<2, 3, 7> placeholder (which may be found pretty usefull) would look like:
template<std::size_t.... Is>
struct group_placeholder {};
template<std::size_t.... Is>
struct is_placeholder<group_placeholder<Is...>> : true_type {};
template<std::size_t.... Is, std::size_t ArgCount>
struct placeholder_positions<group_placeholder<Is...>, ArgCount> : integral_sequence<std::size_t, Is...>
{
//static assert to avoid check if all Is are less ArgCount would be recomended but no actually needed.
};
namespace placeholders
{
template<std::size_t.... Is>
group_placeholder<Is....> _group;
};