Indiana Unversity logo[ConceptGCC]

ConceptGCC :

Using concept associated types

From: K. Noel Belcourt (kbelco_at_[hidden])
Date: 2008-03-01 18:56:23


Hi,

It seems to me that one can use types associated with a concept
without requiring the concept to type check. Is this by design or
just an implementation detail in conceptgcc?

For example, the conceptgcc inner_product function has (essentially)
this signature:

template<InputIterator, _Iter1, InputIterator, _Iter2, typename _Tp>
        HasMultiply<_Iter1::reference, _Iter2::reference> &&
        HasPlus<_Tp, HasMultiply<_Iter1::reference,
_Iter2::reference>::result_type> &&
        CopyAssignable<_Tp,
                HasPlus<_Tp,
                        HasMultiply<_Iter1::reference, _Iter2::reference>::result_type
>::result_type> &&
        CopyConstructible<_Tp>)
_Tp inner_product(_Iter1 __first1, _Iter1 __last1, _Iter2 __first2,
_Tp __init)

If I change this to:

template<InputIterator, _Iter1, InputIterator, _Iter2, typename _Tp>
        CopyAssignable<_Tp,
                HasPlus<_Tp,
                        HasMultiply<_Iter1::reference, _Iter2::reference>::result_type
>::result_type> &&
        CopyConstructible<_Tp>)
_Tp inner_product(_Iter1 __first1, _Iter1 __last1, _Iter2 __first2,
_Tp __init)

the inner_product function fails to type check.

   std::vector<float> u, v;
   float f = 0.5;
   std::inner_product(u.begin(), u.end(), v.begin(), f);

This seems to imply that one can use the types
HasMultiply::result_type and HasPlus::result_type without type
checking the use of the HasMultiply and HasPlus concepts.

Is this just a conceptgcc implementation detail or is the expected
behavior?

Thanks.

-- Noel Belcourt