Le 25/05/13 18:17, Jeffrey Yasskin a �crit :
>> Le 24/05/13 21:49, DeadMG a �crit :
>>
>>> The user doesn't have to give you a template template. You don't pass
>>> allocators as template templates, but allocator_traits::rebind can still
>>> automatically implement rebind in the vast majority of cases. Look at it. --
>>>
>> I don't get what you try to tell me. Please, could you clarify how
>> allocator_traits::rebind could help on what I want to do. Could you show me
>> how to declare my original function
>>
>>
>> template <typename C>
>> //requires IsOptional(ValueType(C))
>> optional<???> if_all(C const& c);
>>
>> so that it works or all the models of container without modifying the
>> standard?
> I think he meant "look at your standard library's implementation of
> allocator_traits::rebind in order to answer your question yourself."
>
Thanks to both for all your help. I was surely looking in the wrong
direction or reading too quickly the posts.
You have never had the solution in face of you and not be able to
getting it at all?
Anyway, IIUC the solution is partial. The default trait of this solution
(Alloc<T, Args>) works only if all the container parameters are types
and the first one is the type to rebind.
template <class C, class T> using rebind = typename
detail::traits_rebind<C, T>::type;
For container having non-type templates, the definition must include its
own rebind, e.g.
template <typename T, size_t N>
struct my_staticaly_bounded_container // std::array?
{
template <class U> using rebind = my_staticaly_bounded_container<U, N>;
};
Is this correct?
If yes, is it wort adding it to the standard so that the users (as me)
can define
template <typename C>
//requires IsOptional(ValueType(C))
optional<rebind<C, typename C::value_type::value_type>> if_all(C
const& c);
Vicente