Boost logo

Boost :

Subject: Re: [boost] [optional] using name boost::in_place -- need your opinion/advice
From: Krzysztof Czainski (1czajnik_at_[hidden])
Date: 2016-05-30 07:40:11


2016-05-30 13:21 GMT+02:00 Krzysztof Czainski <1czajnik_at_[hidden]>:

> 2016-05-30 12:46 GMT+02:00 Andrey Semashev <andrey.semashev_at_[hidden]>:
>
>> On Monday, 30 May 2016 13:45:28 MSK Krzysztof Czainski
>> wrote:
>> > 2016-05-30 11:29 GMT+02:00 Andrey Semashev
>> <andrey.semashev_at_[hidden]>:
>> >
>> > > The typed in-place
>> > > factories ruin the solution though, even if not used by
>> optional.
>> >
>> > How so?
>>
>> Typed in-place factory requires an explicit template parameter
>> to be specified, which is not achievable if in_place is an object.
>>
>
> Oh yeah. Too bad a variable template cannot be "overloaded" with the
> non-template function object.
>

Maybe in_place can be hacked as is without changing it to a function
object? Here's a proof of concept. It compiles [1], so it seems 'in_place'
can be used as a tag with the current implementation of boost::in_place()
overloads.

[1] http://ideone.com/zzbwq4

   1. struct in_place_factory0 {};
   2.
   3. in_place_factory0 in_place() {}
   4. template <class T> void in_place(T) {}
   5. template <class T, class U> void in_place(T, U) {}
   6.
   7. void test(in_place_factory0 (&in_place_tag)()) {}
   8.
   9. int main() {
   10. test(in_place);
   11. }


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk