C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Preprocessor macro __COUNTER__

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 21 Aug 2022 18:10:19 -0300
On Thursday, 18 August 2022 18:47:28 -03 Frederick Virchanza Gotham via Std-
Proposals wrote:
> int main(void)
> {
> SomeClass &objA = Func< __COUNTER__ >();
> SomeClass &objB = Func< __COUNTER__ >();
> SomeClass &objC = Func< __COUNTER__ >();
> SomeClass &objD = Func< __COUNTER__ >();
> SomeClass &objE = Func< __COUNTER__ >();
>
> assert( &objA != &objE );
> }

And what's the motivation to do the above? Using __COUNTER__ with the example
above simply moves the motivation one step further; we'd need to understand

a) why those objects must be instantiated
b) why they must be integers, as opposed to some other type (see Marcin's
reply)
c) what happens if two TUs also use __COUNTER__?
d) what happens to those TUs if the counters are not in phase?

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2022-08-21 21:10:22