Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: TypeErasure
From: Larry Evans (cppljevans_at_[hidden])
Date: 2012-06-26 17:07:13


On 06/26/12 14:18, Steven Watanabe wrote:
> AMDG
>
> On 06/26/2012 11:41 AM, Larry Evans wrote:
>>
>> */libs/type_erasure/doc/html/boost_typeerasure/conceptdef.html
>>
>> states:
>>
>> The template parameters of the concept may involve placeholders.
>>
>> * Each template argument may be a cv and/or reference
>> qualified placeholder type.
>>
>> * If a template argument is a function type, its arguments and
>> return type may be cv/reference qualified placeholders.
>>
>> but, because of the 'may's it doesn't require a placeholder.
>>
>
> That's correct. The errors that you're
> getting stem from a different cause. The
> library doesn't actually require any placeholders,
> although it isn't terribly useful without them.
>
>> Now, obviously, the placeholder is the only way to retrieve the value
>> of the data stored in the any, and you could reason that a placeholder
>> is obviously needed; however, I think that needs to be explicitly
>> stated so there's no confusion (I confess, I was actually confused by
>> this and it took several trials before I finally concluded that a
>> placeholder was required).
>>
>> The attached file, when compiled with:
>>
>> #define MODEL_DEFAULT_SELF
>>
>> compiles and runs OK.
>
> That would be a bug. The code should
> not compile with either setting.
>
>> However, with:
>>
>> //#define MODEL_DEFAULT_SELF
>>
>> gcc4.8 fails to compile it and gives a very obscure error message
>> containing:
>>
>> ../../../boost/type_erasure/call.hpp:530:89: required from 'typename
>> boost::type_erasure::detail::call_result<Op, void(U0&)>::type
>> boost::type_erasure::call(const Op&, U0&) [with Op = concept<>; U0 =
>> int; typename boost::type_erasure::detail::call_result<Op,
>> void(U0&)>::type = void]'
>> concept_ph.cpp:84:5: required from here
>> ../../../boost/type_erasure/detail/get_signature.hpp:23:5: error:
>> incomplete type 'void' used in nested name specifier
>> BOOST_TYPEOF_NESTED_TYPEDEF_TPL(nested, &Concept::apply)
>> ^
>>
>> which seems to support the position that some placeholder is required
>> in the concept's template arguments, AFAICT.
>>
>
> For some reason, gcc tends to make errors with call
> point to BOOST_TYPEOF.
>
> Anyway, I can compile the following just fine with
> MSVC 10.
>
> int i = 0;
> call(binding<incrementable<int> >(mpl::map0<>()),
> incrementable<int>(), i);
> // i = 1
>
> The problems with your code are:
>
> a) call(concept<int>(), y)
> - The library cannot deduce the the
> binding because none of the arguments
> is an any.
> b) call(concept<_self>(), a_any)
> - concept<_self> is not part of the requirements
> of a_any.

I tried the b) case again and it does not compile. I must of
accidentally rm'ed the concept<> from the
requirements while posting the code. I remember making
a bunch of "minor" edits to make the code more presentable,
and I must have failed to test compile it after the last
edit :(

Sorry for that typo. When corrected, and when:

#define MODEL_DEFAULT_SELF

the run is:

./concept_ph.exe
:e=empty
:apply(empty )

Thanks for the explanation.


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