Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-08-31 07:47:04


Tobias Schwinger <tschwinger_at_[hidden]> writes:

> I'll continue this discussion (previously in private email) on the
> boost mailinglist, in order to allow others to join in.
>
> Any critiques (i.e. having a look at the (comparatively small)
> submission and dropping me a couple of lines) are still very welcome,
> in fact !
>
> Alexander Nasonov wrote:
>
>>>> [... char array in struct as sizer for type classification via
>>>> overload resultion ...]
>>>>
>>> Good point. This will be changed. By the way: the same hack is in
>>> the current boost release
>>> [boost/type_tratis/function_traits.hpp:177].
>>>
>>>
>>>
> This has been changed [ref. 5.3.3].
>
>>>> // tester returns a reference to an array
>>>> template< /* ... */ >
>>>> char (& tester( /* ... */ ) ) [size];
>>>>
>>>>
> This would have been my personal preference. Unfortunately this causes
> bcc to fail with an 'Internal compiler error'.

Just use an external template

  template< /* ... */ >
  typename char_array<size>::type tester( /* ... */ );

(See boost/python/detail/char_array.hpp)

>>>>or making it a meta-function
>>>>
>>>> template<std::size_t Size>
>>>> struct sized_type
>>>> {
>>>> typedef char (&type)[Size];
>>>> };
>>>>
>>>>and using typename sized_type<Size>::type in place of sized_type<Size>.
>>>>
>>>>
>>>>
> This is the current, but not necessarily the best implementation. Comments ?

Whoops! That's basically what I did. If you need to represent zero
it has to change slightly.

> I believe this could be a common issue - for that matter:
>
> What about a type synthesizer like 'type_with_size<size_t>::type' or a
> BOOST_TYPE_WITH_SIZE(n)' macro ?
> Or even:
> BOOST_SIZED_RESULT_TYPE_OVERLOAD_PROTO(template_args,function_args,size_expression).
>
> Is there something like this in boost somewhere, already ?

See above.

>>>I sure will !
>>>
>>> Thanks a lot for your work, ideas and the very nice mail - despite
>>> the fact of having no time, that is !
>>>
>>>
>>
>>Have you considered wrapping function signature into mpl sequence?
>>
>>
> Currently function_signature<T>::type is an mpl::vector and therefore
> a model of sequence.

Have you seen boost/python/detail/signature.hpp?

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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