Click here to Skip to main content
15,901,373 members

Welcome to the Lounge

   

For discussing anything related to a software developer's life but is not for programming questions. Got a programming question?

The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.

 
Joke(Bad) Joke PinPopular
Brisingr Aerowing13-Nov-21 17:00
professionalBrisingr Aerowing13-Nov-21 17:00 
GeneralRe: (Bad) Joke Pin
Slow Eddie14-Nov-21 8:39
professionalSlow Eddie14-Nov-21 8:39 
GeneralRe: (Bad) Joke Pin
obermd15-Nov-21 6:29
obermd15-Nov-21 6:29 
QuestionI love C++ template specializations Pin
honey the codewitch13-Nov-21 11:13
mvahoney the codewitch13-Nov-21 11:13 
AnswerRe: I love C++ template specializations Pin
Greg Utas13-Nov-21 13:54
professionalGreg Utas13-Nov-21 13:54 
GeneralRe: I love C++ template specializations Pin
honey the codewitch13-Nov-21 14:17
mvahoney the codewitch13-Nov-21 14:17 
GeneralRe: I love C++ template specializations Pin
Greg Utas13-Nov-21 14:32
professionalGreg Utas13-Nov-21 14:32 
GeneralRe: I love C++ template specializations Pin
honey the codewitch13-Nov-21 14:38
mvahoney the codewitch13-Nov-21 14:38 
In my GFX project I allow drivers to expose different methods depending on what their hardware supports. GFX will use them when available for better performance.

You tell gfx what you want by exposing a caps "using" and filling it with what you support like this:

Supports only batching:
C++
using caps = gfx::gfx_caps<false,false,true,false,false,false,false>;


Supports everything but read ops and direct blts:
C++
using caps = gfx::gfx_caps<false,false,true,true,false,false,false>;


Each of those fields has a named argument to tell you what it is, so it's not as confusing as it looks.

If you mark a field as true, you *must* implement the methods necessary to support that feature. For example, if you mark your target as readable, you must implement the method to read a pixel from its framebuffer.

This caps template is examined through partial template specializations, and the different methods are called based on its values. It chooses the best method it can to perform an operation, and falls back when the caps doesn't support it.

This isn't really possible to do any other way, except at runtime, and that comes with lots of overhead and additional code size for unused code.
Real programmers use butterflies

GeneralRe: I love C++ template specializations Pin
Greg Utas14-Nov-21 0:58
professionalGreg Utas14-Nov-21 0:58 
GeneralRe: I love C++ template specializations Pin
honey the codewitch14-Nov-21 5:26
mvahoney the codewitch14-Nov-21 5:26 
GeneralRe: I love C++ template specializations Pin
englebart14-Nov-21 4:35
professionalenglebart14-Nov-21 4:35 
GeneralRe: I love C++ template specializations Pin
honey the codewitch14-Nov-21 5:23
mvahoney the codewitch14-Nov-21 5:23 
GeneralSomeone answer here, please Pin
Nelek13-Nov-21 7:29
protectorNelek13-Nov-21 7:29 
GeneralRe: Someone answer here, please Pin
ElectronProgrammer13-Nov-21 7:39
ElectronProgrammer13-Nov-21 7:39 
GeneralRe: Someone answer here, please Pin
Nelek13-Nov-21 11:23
protectorNelek13-Nov-21 11:23 
GeneralRe: Someone answer here, please Pin
Gary R. Wheeler14-Nov-21 2:37
Gary R. Wheeler14-Nov-21 2:37 
GeneralRe: Someone answer here, please Pin
0x01AA13-Nov-21 7:44
mve0x01AA13-Nov-21 7:44 
GeneralRe: Someone answer here, please Pin
OriginalGriff13-Nov-21 8:39
mveOriginalGriff13-Nov-21 8:39 
GeneralRe: Someone answer here, please Pin
0x01AA13-Nov-21 8:50
mve0x01AA13-Nov-21 8:50 
GeneralRe: Someone answer here, please Pin
OriginalGriff13-Nov-21 8:55
mveOriginalGriff13-Nov-21 8:55 
GeneralRe: Someone answer here, please Pin
0x01AA13-Nov-21 8:57
mve0x01AA13-Nov-21 8:57 
GeneralRe: Someone answer here, please Pin
OriginalGriff13-Nov-21 9:23
mveOriginalGriff13-Nov-21 9:23 
GeneralRe: Someone answer here, please Pin
Nelek13-Nov-21 11:21
protectorNelek13-Nov-21 11:21 
GeneralRe: Someone answer here, please Pin
Gary R. Wheeler14-Nov-21 2:39
Gary R. Wheeler14-Nov-21 2:39 
GeneralRe: Someone answer here, please Pin
OriginalGriff14-Nov-21 2:53
mveOriginalGriff14-Nov-21 2:53 

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.


Straw Poll

Were you affected by the geomagnetic storms this past weekend?
Communication disruptions, electrified pipes, random unexplained blue-screens in Windows - the list of effects is terrifying.
  Results   507 votes