Date: Wed, 17 Mar 2021 17:12:45 -0400
It won't create a run-time virtual table.
On 3/17/21 5:03 PM, Andrey Semashev via Std-Proposals wrote:
> On 3/17/21 10:41 PM, Phil Bouchard via Std-Proposals wrote:
>> New keyword proposal to allow inheritance at compile-time. Ex:
>>
>> template <typename T>
>>
>> struct container
>>
>> {
>>
>> static_virtual T * begin() {...}
>>
>> static_virtual T * end() {...}
>>
>> static_virtual T * rbegin() {...}
>>
>> static_virtual T * rend() {...}
>>
>> };
>>
>> template <typename T>
>>
>> struct list : container<T>
>>
>> {
>>
>> static_virtual T * begin() {...}
>>
>> static_virtual T * end() {...}
>>
>> static_virtual T * rbegin() {...}
>>
>> static_virtual T * rend() {...}
>>
>> };
>>
>> template <typename T>
>>
>> ostream & ostream(ostream & out, container<T> const & c)
>>
>> {
>>
>> for (auto i = c.begin(); i != c.end(); ++ i)
>>
>> out << * i << endl;
>>
>> return out;
>>
>> }
>>
>> int main()
>>
>> {
>>
>> list<int> l;
>>
>> l.push_back(1);
>>
>> l.push_back(2);
>>
>> l.push_back(3);
>>
>> cout << l << endl;
>>
>> }
>
> I'm not sure how it is different from the good old virtual.
On 3/17/21 5:03 PM, Andrey Semashev via Std-Proposals wrote:
> On 3/17/21 10:41 PM, Phil Bouchard via Std-Proposals wrote:
>> New keyword proposal to allow inheritance at compile-time. Ex:
>>
>> template <typename T>
>>
>> struct container
>>
>> {
>>
>> static_virtual T * begin() {...}
>>
>> static_virtual T * end() {...}
>>
>> static_virtual T * rbegin() {...}
>>
>> static_virtual T * rend() {...}
>>
>> };
>>
>> template <typename T>
>>
>> struct list : container<T>
>>
>> {
>>
>> static_virtual T * begin() {...}
>>
>> static_virtual T * end() {...}
>>
>> static_virtual T * rbegin() {...}
>>
>> static_virtual T * rend() {...}
>>
>> };
>>
>> template <typename T>
>>
>> ostream & ostream(ostream & out, container<T> const & c)
>>
>> {
>>
>> for (auto i = c.begin(); i != c.end(); ++ i)
>>
>> out << * i << endl;
>>
>> return out;
>>
>> }
>>
>> int main()
>>
>> {
>>
>> list<int> l;
>>
>> l.push_back(1);
>>
>> l.push_back(2);
>>
>> l.push_back(3);
>>
>> cout << l << endl;
>>
>> }
>
> I'm not sure how it is different from the good old virtual.
-- *Phil Bouchard* Founder C.: (819) 328-4743 Fornux Logo <http://www.fornux.com>
Received on 2021-03-17 16:12:55