Click here to Skip to main content
15,991,888 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Dynamic SQL Pin
Shane010330-Jun-24 18:07
Shane010330-Jun-24 18:07 
GeneralRe: Dynamic SQL Pin
raddevus1-Jul-24 2:11
mvaraddevus1-Jul-24 2:11 
GeneralRe: Dynamic SQL Pin
Daniel Pfeffer30-Jun-24 19:17
professionalDaniel Pfeffer30-Jun-24 19:17 
GeneralRe: Dynamic SQL Pin
Richard Deeming30-Jun-24 21:31
mveRichard Deeming30-Jun-24 21:31 
GeneralRe: Dynamic SQL Pin
Pete O'Hanlon30-Jun-24 21:45
mvePete O'Hanlon30-Jun-24 21:45 
GeneralRe: Dynamic SQL Pin
jochance2-Jul-24 7:14
jochance2-Jul-24 7:14 
GeneralRe: Dynamic SQL Pin
Sander Rossel9-Jul-24 1:05
professionalSander Rossel9-Jul-24 1:05 
GeneralHow, VS Code? This is amazing. Pin
honey the codewitch22-Jun-24 14:51
mvahoney the codewitch22-Jun-24 14:51 
The intellisense for C++ in VS Code - at least when it works, is nothing short of incredible.

C++
template<size_t BitDepth>
using bgrx_pixel = pixel<
	channel_traits<channel_name::B,(BitDepth/4)>,
    channel_traits<channel_name::G,((BitDepth/4)+(BitDepth%4))>,
    channel_traits<channel_name::R,(BitDepth/4)>,
	channel_traits<channel_name::nop,(BitDepth/4)>    
>;

using rgb18_pixel = pixel<
    channel_traits<channel_name::R,6>,
    channel_traits<channel_name::nop,2>,
    channel_traits<channel_name::G,6>,
    channel_traits<channel_name::nop,2>,
    channel_traits<channel_name::B,6>,
    channel_traits<channel_name::nop,2>
>;


What you're looking at is two arbitrarily defined pixels. One is N-bit pixel where 3/4 of the bits are used, and the second example is a 24-bit pixel where 18-bits are used.

That's not really important, but the channel names are, because consider this:

C++
rgb18_pixel::is_color_model<
            channel_name::R,
            channel_name::G,
            channel_name::B>::value


If you know C++ you can tell there's metaprogramming magic here. What I'm doing is querying a "list" of channel traits at compile time looking for ones with particular names.

The thing is, if you hover over value, the extension will resolve it to true in the tooltip that pops up - no easy feat.

More impressive even is this:

C++
using color18_t = color<rgb18_pixel>;
auto px = color18_t::gray;


It will determine the actual numeric value for that color and display it when you hover over "gray"
(2155905024)

You think that's easy? No.

C++
constexpr static const PixelType gray = convert<source_type,PixelType>(color<PixelType>::source_type(true, 
    0.501960784313725, 
    0.501960784313725, 
    0.501960784313725));


Notice it's running a constexpr function convert() to get the destination pixel format. This is a non-trivial function.

So one of two things is happening here.

Either the C++ extension for VS Code has a compliant C++ compiler front and middle built in (I suspect it does) or it is managing to link itself to existing compilers like GCC tightly enough to determine this output (which doesn't seem possible to me)

Either way, go Microsoft.
Check out my IoT graphics library here:
https://honeythecodewitch.com/gfx
And my IoT UI/User Experience library here:
https://honeythecodewitch.com/uix

GeneralRe: How, VS Code? This is amazing. Pin
Richard Andrew x6423-Jun-24 4:32
professionalRichard Andrew x6423-Jun-24 4:32 
GeneralRe: How, VS Code? This is amazing. Pin
honey the codewitch23-Jun-24 4:35
mvahoney the codewitch23-Jun-24 4:35 
GeneralRe: How, VS Code? This is amazing. Pin
Richard Andrew x6423-Jun-24 4:45
professionalRichard Andrew x6423-Jun-24 4:45 
GeneralRe: How, VS Code? This is amazing. Pin
honey the codewitch23-Jun-24 4:46
mvahoney the codewitch23-Jun-24 4:46 
GeneralRe: How, VS Code? This is amazing. Pin
Dave Kreskowiak23-Jun-24 6:11
mveDave Kreskowiak23-Jun-24 6:11 
GeneralRe: How, VS Code? This is amazing. Pin
Luschan25-Aug-24 19:32
Luschan25-Aug-24 19:32 
GeneralWhat the hell gcc? Pin
honey the codewitch17-Jun-24 21:20
mvahoney the codewitch17-Jun-24 21:20 
GeneralRe: What the hell gcc? Pin
RainHat17-Jun-24 22:57
RainHat17-Jun-24 22:57 
GeneralRe: What the hell gcc? Pin
honey the codewitch17-Jun-24 22:58
mvahoney the codewitch17-Jun-24 22:58 
GeneralRe: What the hell gcc? Pin
RainHat18-Jun-24 0:51
RainHat18-Jun-24 0:51 
GeneralRe: What the hell gcc? Pin
0x01AA18-Jun-24 1:23
mve0x01AA18-Jun-24 1:23 
GeneralRe: What the hell gcc? Pin
honey the codewitch18-Jun-24 4:12
mvahoney the codewitch18-Jun-24 4:12 
GeneralRe: What the hell gcc? Pin
jochance18-Jun-24 2:59
jochance18-Jun-24 2:59 
GeneralRe: What the hell gcc? Pin
k505418-Jun-24 3:17
mvek505418-Jun-24 3:17 
GeneralRe: What the hell gcc? Pin
Rick York18-Jun-24 4:53
mveRick York18-Jun-24 4:53 
GeneralRe: What the hell gcc? Pin
honey the codewitch18-Jun-24 5:03
mvahoney the codewitch18-Jun-24 5:03 
GeneralRe: What the hell gcc? Pin
k505418-Jun-24 5:20
mvek505418-Jun-24 5:20 

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.