
Sebastian Redl wrote:
Spencer Collyer wrote:
Whilst working on a policy-based sparse-array class (which I hope to submit to Boost at some point), I had the problem that there did not seem to be any sensible way to organise the policies such that sensible defaults could be coded in the template. Rather than always forcing the users to specify the earlier policies, even when the default would be fine, simply because they wanted to use a different policy for one of the later parameters, I came up with the following little utility.
This looks like a very nice utility, and I'm sure it could find application. A library facing a similar problem is the iterator library, where the use_default mechanism was used. In this particular case, however, your method is not applicable as it is, because the parameters specified by use_default can be primitives.
The iterator library is different because it takes its template parameters individually, not as an MPL sequence. I'm working on a Named Template Parameters library which would address the needs of the iterator library. It's fully functional (passing 400-some tests) but the documentation is lagging. I literally just ran into a need for the policy selector this morning and was going to quickly code something up but Spencer beat me to it. :) I'd love to see something like this in Boost. It would complement NTP very nicely. -Dave