Click here to Skip to main content
16,004,887 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Okay, real C++ question - who makes use of the auto keyword? Pin
jschell29-May-24 5:26
jschell29-May-24 5:26 
GeneralRe: Okay, real C++ question - who makes use of the auto keyword? Pin
trønderen29-May-24 6:53
trønderen29-May-24 6:53 
GeneralRe: Okay, real C++ question - who makes use of the auto keyword? Pin
charlieg21-May-24 8:02
charlieg21-May-24 8:02 
AnswerRe: Okay, real C++ question - who makes use of the auto keyword? Pin
11917640 Member 21-May-24 22:09
11917640 Member 21-May-24 22:09 
GeneralRe: Okay, real C++ question - who makes use of the auto keyword? Pin
charlieg21-May-24 23:47
charlieg21-May-24 23:47 
GeneralRe: Okay, real C++ question - who makes use of the auto keyword? Pin
11917640 Member 22-May-24 0:00
11917640 Member 22-May-24 0:00 
GeneralRe: Okay, real C++ question - who makes use of the auto keyword? Pin
charlieg22-May-24 0:05
charlieg22-May-24 0:05 
AnswerRe: Okay, real C++ question - who makes use of the auto keyword? Pin
honey the codewitch13-Jun-24 12:43
mvahoney the codewitch13-Jun-24 12:43 
There is a time and a place for it, and it's sometimes useful when doing some heavy Generic Programming.

Like, in theory if you had to design your own tuple type (I know std already has one, but ignoring that), the function to access a tuple's value might be an auto because it's difficult to even type out the template instantiation necessary for the return type, much less come up with it.

Another place I use it: In my graphics library you can define pixels with an arbitrary memory footprint. Different amounts of bits for different channels, like RGB565 or YUV888 etc. Because of the arbitrary nature of it the integer values for each channel may be a different type. For example, while a channel probably won't be more than a uint8_t can hold (8-bits) it might be (12 bits? uint16_t would be necessary)

Because of that, when I go to assign values from arbitrary pixel formats I don't actually *know* what type it is, other than some kind of integer of 64 bits or less (based on static_assert constraints). So I could always promote it to a uint64_t but that creates other problems when you have to cast down again.

So auto is what's for dinner.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

Questionmfc, vs2022 compatible? Pin
charlieg17-May-24 7:21
charlieg17-May-24 7:21 
AnswerRe: mfc, vs2022 compatible? Pin
Victor Nijegorodov17-May-24 7:39
Victor Nijegorodov17-May-24 7:39 
GeneralRe: mfc, vs2022 compatible? Pin
charlieg17-May-24 7:56
charlieg17-May-24 7:56 
AnswerRe: mfc, vs2022 compatible? Pin
RedDk17-May-24 9:39
RedDk17-May-24 9:39 
GeneralRe: mfc, vs2022 compatible? Pin
charlieg17-May-24 10:51
charlieg17-May-24 10:51 
GeneralRe: mfc, vs2022 compatible? Pin
RedDk17-May-24 11:11
RedDk17-May-24 11:11 
AnswerRe: mfc, vs2022 compatible? Pin
Maximilien21-May-24 5:31
Maximilien21-May-24 5:31 
GeneralRe: mfc, vs2022 compatible? Pin
charlieg21-May-24 5:51
charlieg21-May-24 5:51 
GeneralRe: mfc, vs2022 compatible? Pin
Maximilien21-May-24 8:02
Maximilien21-May-24 8:02 
GeneralRe: mfc, vs2022 compatible? Pin
charlieg21-May-24 8:03
charlieg21-May-24 8:03 
QuestionC++ language updates / old C++ code Pin
HobbyProggy14-May-24 20:12
professionalHobbyProggy14-May-24 20:12 
AnswerRe: C++ language updates / old C++ code Pin
CPallini15-May-24 1:48
mveCPallini15-May-24 1:48 
GeneralRe: C++ language updates / old C++ code Pin
HobbyProggy15-May-24 20:30
professionalHobbyProggy15-May-24 20:30 
GeneralRe: C++ language updates / old C++ code Pin
CPallini20-May-24 20:07
mveCPallini20-May-24 20:07 
AnswerRe: C++ language updates / old C++ code Pin
Maximilien15-May-24 2:03
Maximilien15-May-24 2:03 
GeneralRe: C++ language updates / old C++ code Pin
HobbyProggy15-May-24 20:37
professionalHobbyProggy15-May-24 20:37 
GeneralRe: C++ language updates / old C++ code Pin
k505415-May-24 5:38
mvek505415-May-24 5:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.