[c++-concepts]
Andrew Sutton
andrew.n.sutton@gmail.com
Thu May 30 20:48:00 GMT 2013
I presented that at C++Now, so I hope so :) It lets me write:
template<typename T>
requires Input_iterator<T> // no parens!
void f(T x);
Walter Brown also suggested this usage in his object alias paper.
In concepts lite, a concept is essentially an expression. Thus far,
we've packaged those expressions in constexpr functions (using
"concept" as a declaration specifier to impose additional
restrictions). Variable templates fall easily into this same set of
restrictions. Plus, no overloading.
Andrew
On Thu, May 30, 2013 at 3:34 PM, Jason Merrill <jason@redhat.com> wrote:
> On 05/30/2013 03:17 PM, Andrew Sutton wrote:
>>>
>>> | - /* 1 spare bit */
>>> | + unsigned concept_p : 1; /* var or fn */
>>> | + /* 0 spare bit */
>>> | };
>>>
>>> Hmm I don't understand the comment "var or fn".
>>> If it is declared a concept, how can it it be a var?
>>
>>
>> Copied from the other bits in the class. I think it means it applies
>> to either variables or functions. I left it that way in anticipation
>> of template variables.
>
>
> Can template variables be concepts?
>
> Jason
>
--
Andrew Sutton
andrew.n.sutton@gmail.com
More information about the Gcc-patches
mailing list