|
template argument deduction matches the types of the arguments against the declared form of the parameters, trying to make them the same. if your template is declared likecode:
but it does this purely by structurally decomposing the template parameter type in specific ways, so if instead you write: code:
this can be useful in your own templates. e.g. if you take two arguments and one is an l-value and the other is a value that you want to assign to it, you don't want to write your template like code:
code:
|
# ? Oct 1, 2016 09:49 |
|
|
# ? Jun 5, 2024 03:51 |
|
This of course has the problem of potentially performing a costly conversion in addition to a copy (think assigning const char* to std::string) so you obviously have to template harder.C++ code:
So that eliminated the conversion if possible. Now how about copies? Well thats where perfect forwarding comes back.* C++ code:
Its important to remember that this doesn't work without the std::forward properly, because r-values really like to stop moving. Once you name them, even if you have r-value reference to a temporary, they are no longer moved automatically. This means that this C++ code:
C++ code:
C++ code:
C++ code:
C++ code:
The above might not be entirely true, I haven't even had my first coffee, but it should be roughly correct.
|
# ? Oct 1, 2016 11:20 |
|
Shaggar posted:Microsoft was writing the best ui frameworks and languages 10 years ago. wpf and winforms are basically abandoned except for critical fixes. all they really have for current poo poo is UWP and just lol at using UWP.
|
# ? Oct 1, 2016 15:56 |
|
Soricidus posted:only the last decade? what was better in 2005? java was probably a better language back then fleshweasel posted:wpf and winforms are basically abandoned except for critical fixes. all they really have for current poo poo is UWP and just lol at using UWP. winforms hasn't changed in years and uwp is wpf
|
# ? Oct 1, 2016 16:03 |
|
uwp/wpf are also better than anything else as far as ui frameworks go
|
# ? Oct 1, 2016 16:04 |
|
isn't the only distinction between uwp and wpf the os you're running on?
|
# ? Oct 1, 2016 16:17 |
|
no uwp is a reimplementation of wpf from scratch in c++, with some differences, both better and worse. for example: no support for control triggers, but it has a static alternative to bindings. they aren't compatible at all - you can't write code that is useful for both, though you can use standard techniques to have a model/business logic layer that's shared of course.
|
# ? Oct 1, 2016 16:23 |
|
uwp is pretty nice *as an api*. there are a few major hassles about it logistically though, all stemming from the bizarre choice to try and make .NET non-mandatory: - controls are reference-counted not garbage collected, and it's easy to leak memory - you can't publish components which reference non-COM types (!) - debug builds and release builds use a totally different process, with release taking 10x longer and compiling to native code with semi-broken reflection. you have to test separately in both - no controltriggers, only the silverlight-style visualstatemanager (which sucks imo) and of course - only works on windows 10 for business applications there is really no reason to switch to it.
|
# ? Oct 1, 2016 16:25 |
|
Shaggar posted:uwp/wpf are also better than anything else as far as ui frameworks go Why do then the new MS UWP apps suck so drat badly?
|
# ? Oct 1, 2016 16:42 |
|
Xarn posted:Why do then the new MS UWP apps suck so drat badly? i freely admit that i am an idiot and a sucker for being pointlessly different in having a w10m phone, but holy hell the few high effort uwp apps i have encountered have been fantastic. mail, calendar, the new skype, as well as minor stuff like the explorer app even. no idea if that is microsoft throwing excessive engineering resources on a bad framework, but they are certainly making the framework looking super-promising to me in a way the previous wpf variant never did vv
|
# ? Oct 1, 2016 19:03 |
|
uwp is hot garbage that serves no purpose. nobody uses windows phone so uwp brings nobody new to the platform. if you already put up with wpf it is an entirely pointless reimplementation with zero attraction. having zero audience leads to decreasing support from microsoft and the death spiral of uwp the worst that can be said about wpf is that it is competitive with ui frameworks on other platforms that have similar goals. if you have similar tastes as shaggar maybe it is the gold standard, if you're a little more circumspect it is merely fine wpf can absolutely be improved, but uwp has no claim to that mantle. can't wait to see what the next lovely reimplementation of wpf looks like! we'll get it right this time! why is the silverlight team laughing at us?
|
# ? Oct 1, 2016 19:14 |
|
here is my example of pointless lovely reimplementation this is the wpf tilebrush this is the uwp tilebrush are there any properties on the wpf one that seem oddly absent from the uwp one? how about TileMode you know, the property that controls how the contents are tiled oh, we took that out of uwp? so TileBrush doesn't tile but we kept the class hierarchy for... convenience?
|
# ? Oct 1, 2016 19:21 |
|
pokeyman posted:here is my example of pointless lovely reimplementation wpf and uwp are a product of microsofts divisions fighting each other WinRT is like totally different to everything else. by design. sinofsky lmao
|
# ? Oct 1, 2016 19:28 |
|
why does microsoft have like twenty different drawing apis i still use GDI+ and it works fine
|
# ? Oct 1, 2016 19:29 |
|
but it's not totally different, that's my point. totally different might make sense
|
# ? Oct 1, 2016 19:46 |
|
Malcolm XML posted:wpf and uwp are a product of microsofts divisions fighting each other dealing with 8.1 vs 10 can be a real pain in the rear end and i can confirm this because ive had to deal with it
|
# ? Oct 1, 2016 19:48 |
|
pokeyman posted:but it's not totally different, that's my point. totally different might make sense internally its totally different and they papered over the differences w/ whatever the gently caress uwp is
|
# ? Oct 1, 2016 19:56 |
|
yeah ms continues to have one of the best web stacks imaginable but i have no clue what they're even aiming for on the desktop.
|
# ? Oct 1, 2016 20:04 |
|
Cybernetic Vermin posted:i freely admit that i am an idiot and a sucker for being pointlessly different in having a w10m phone, but holy hell the few high effort uwp apps i have encountered have been fantastic. mail, calendar, the new skype, as well as minor stuff like the explorer app even. no idea if that is microsoft throwing excessive engineering resources on a bad framework, but they are certainly making the framework looking super-promising to me in a way the previous wpf variant never did vv The new skype for me A) Doesnt send/receive chat messages to people I tried. B) Doesnt show status of people (and people dont see my status either). I guess it at least allows for calling people. (At least once we use different app to communicate being online ) Now, I might just have a horrible case of "Doesn't work on my computer", but it doesn't inspire much confidence...
|
# ? Oct 1, 2016 20:43 |
|
have not seen that, i have switched over entirely, and have been very happy with it not much to go by granted. otoh the complaint that microsoft has had a bad run of eol'ing stuff people like and use for a slightly different replacement is, while valid, sort of beside the point about uwp being good/bad
|
# ? Oct 1, 2016 22:32 |
|
Xarn posted:Why do then the new MS UWP apps suck so drat badly? a lot (most or all??) of the built in Windows 10 desktop store apps are actually written in html+javascript, which can call UWP APIs in a technically impressive but also insane way. the entire reason they made UWP is that the Windows division refuses to use C#.
|
# ? Oct 2, 2016 01:25 |
|
Gul Banana posted:the Windows division refuses to use C#. oh my god.
|
# ? Oct 2, 2016 01:29 |
|
Gul Banana posted:the entire reason they made UWP is that the Windows division refuses to use C#. this explains so much
|
# ? Oct 2, 2016 01:34 |
|
did they just look at C#/.net and say "hmmm this looks really straightforward, it's not an appropriate replacement for win32"
|
# ? Oct 2, 2016 01:38 |
|
hobbesmaster posted:did they just look at C#/.net and say "hmmm this looks really straightforward, it's not an appropriate replacement for win32" you know what makes less sense but would make it easier for me to get a job in SF 8 months from now? javascript
|
# ? Oct 2, 2016 01:43 |
|
this actually makes a lot of sense, especially considering MS's arbitrary firing practices
|
# ? Oct 2, 2016 01:54 |
|
hobbesmaster posted:did they just look at C#/.net and say "hmmm this looks really straightforward, it's not an appropriate replacement for win32" performance reasons made them do winrt, i.e. the revenge of COM, so that u could use C++ not a lot is in winjs iirc and it's basically dead pokeyman posted:this explains so much reminder that most of windows 8 ui stuff was developed in secret and even devdiv didn't know a lot of it
|
# ? Oct 2, 2016 02:00 |
|
man i really did miss COM objects for a bit, thank god .Net has my rear end
|
# ? Oct 2, 2016 02:04 |
|
Malcolm XML posted:performance reasons made them do winrt, i.e. the revenge of COM, so that u could use C++ is .net core part of winrt or otherwise reliant on it? also wasn't there some other managed c++ thing before uwp's managed c++ thing? were those deemed insufficiently performant? it's not obvious to me that wpf etc. are fundamentally incapable of meeting performance goals but idk anything also using uwp apps doesn't make me think "hot drat this performance is super keen". I assume that bet paid off handsomely in some other way. no doubt idiotic politics and pointless emphasis on programmer comfort are benefits that the end user can confidently expect to realize any decade now
|
# ? Oct 2, 2016 02:45 |
|
Gul Banana posted:a lot (most or all??) of the built in Windows 10 desktop store apps are actually written in html+javascript, which can call UWP APIs in a technically impressive but also insane way. this sounds juicy
|
# ? Oct 2, 2016 03:20 |
|
pokeyman posted:is .net core part of winrt or otherwise reliant on it? also wasn't there some other managed c++ thing before uwp's managed c++ thing? were those deemed insufficiently performant? it's not obvious to me that wpf etc. are fundamentally incapable of meeting performance goals but idk anything yeah but c++/cli was managed and c++/cx is unmanaged and this account for the screaming performance of winrt apps also some guy wrote a modern CPP projection of the winrt stuff
|
# ? Oct 2, 2016 03:50 |
|
Malcolm XML posted:yeah but c++/cli was managed and c++/cx is unmanaged and this account for the screaming performance of winrt apps I see quote:also some guy wrote a modern CPP projection of the winrt stuff a what?
|
# ? Oct 2, 2016 04:01 |
|
pokeyman posted:I see yeah
|
# ? Oct 2, 2016 04:06 |
|
[quote="rjmccall" post=""464854498"] and you pass it a const char * then template argument deduction will say aha, i can make those two types the same by assigning T = const char but it does this purely by structurally decomposing the template parameter type in specific ways, so if instead you write: code:
[/quote] ah i see. because std::forward declares its parameter type using a typename member (in this case remove_reference), and type deduction only operates basically on syntax, it can't ever match so you're forced to be explicit. Xarn posted:* Perfect forwarding with strings can also be a hilariously bad idea, in case you use the function with string literals, because then the function isn't deduced as this… could be a problem for my log wrapper
|
# ? Oct 2, 2016 07:48 |
|
Xarn posted:* Perfect forwarding with strings can also be a hilariously bad idea, in case you use the function with string literals, because then the function isn't deduced as dont forget when you perfectly forward a function that it won't decay to a function pointer, but will be treated as a function reference C++ code:
C++ code:
C++ code:
|
# ? Oct 2, 2016 09:36 |
|
pokeyman posted:a what? a winrt "projection" is a set of bindings and idioms which allow code in some specific target environment to *consume* and optionally *author* winrt components. so in the .NET project, winrt types appear as .net types and .net classes which meet certain restrictions can be read by winrt; similarly for c++/cx and for the javascript projection, winjs. winjs looks like this: code:
|
# ? Oct 2, 2016 12:29 |
|
Gul Banana posted:ok, this is technically actually interesting. WinRT is the successor to COM, right? it's an ABI, not language specific. winmd files (the same format as .net) replace IDL. you can use it like you would COM, with complex api call sequences and macros and templates in c++.. but that wouldn't be good enough for app authoring so they did a new thing: projections. that's pretty cool but I'd still rather be using wpf than anything it enables
|
# ? Oct 2, 2016 12:39 |
|
pointsofdata posted:that's pretty cool but I'd still rather be using wpf than anything it enables
|
# ? Oct 2, 2016 13:20 |
|
actually tho thanks for explaining. when I was doing a uwp app it seemed impossible to find anything about it in this level, it was all lovely marketing level "write once run everywhere" bs
|
# ? Oct 2, 2016 13:31 |
|
|
# ? Jun 5, 2024 03:51 |
|
Gul Banana posted:it's a pretty impressive piece of technical magic let down a bit by how it's useless and nobody wants it. ah, IJW interop's spiritual successor
|
# ? Oct 2, 2016 21:04 |