Comments (6)
I've created #93 which adds put_void()
and put_unknown()
to com_ptr
and allows you to pass a CLSID to wil::CoCreateInstance
.
from wil.
Wow, that was quick, awesome!
I like the new overloads for CoCreateInstance
-- now my code will look much nicer.
The new put_void
member fn matches other smart COM pointers, so it makes transition a bit easier, so that's also nice. I wonder about put_unknown
-- IUnknown is the base interface, but in some cases com calls do return other interfaces, e.g. ID2D1Factory::CreateWicBitmapRenderTarget
returns ID2D1RenderTarget
, where you might actually want to hold ID2D1BitmapRenderTarget
. So, I'm thinking it might be better to have a member function template, say put_as<T>
(with a better name though!), that does the reinterpret_cast
, possibly with an extra check to ensure that T
is the base class of whatever interface is held by the smart pointer?
from wil.
Wow talk about consistency :/
Since this is still a PR, would you be fine with just put_as<void>
instead of put_void
?
from wil.
Absolutely! Whatever you think is best.
Just pointing out, that a separate put_void
is consistent with com_ptr::put_void
in WinRT, so that's one less search & replace when switching between the two. Personally, I don't care about that (at all), so feel free to get rid of it...
from wil.
but in some cases com calls do return other interfaces, e.g.
ID2D1Factory::CreateWicBitmapRenderTarget
returnsID2D1RenderTarget
, where you might actually want to holdID2D1BitmapRenderTarget
.
After rereading don't think this is a great idea. You should use an wil::com_ptr<ID2D1RenderTarget>
and use QueryInterface
after the call to make sure it is actually an ID2D1BitmapRenderTarget
, because you never know when that implementation detail may be changed.
from wil.
That's a very good point! In that case, there's nothing else to be added to your fix, I think.
Thanks!
from wil.
Related Issues (20)
- warning C6001 HOT 1
- simple_event seems to be unusable - Compilation error with wil::simple_event, const vs non-cost handler. HOT 2
- Synchronous generator support for IIterable<T> HOT 1
- Some questions about wil::reg HOT 3
- `single_threaded_property` should not be externally writeable HOT 4
- `untyped_event` and `typed_event` do not work for events that don't derive from `EventHandler` or `TypedEventHandler` (eg `Windows.UI.Xaml.Data.CurrentChangingEventHandler`) HOT 2
- [C++/WinRT] Helpers to make it easier to copy data from one collection type (std::initializer_list, etc.) to another (IVector, ValueSet, etc.) HOT 4
- Allow getting array_view/span out of IBuffer and IMemoryBuffer HOT 6
- wil should add GUID-related APIs HOT 4
- wil::zwstring_view should have a constructor that takes a winrt::hstring
- unique_hlocal_string should be available under UWP
- Add compile-time parameter checking for _MSG macros HOT 22
- WIL diagnostic level 2 not working HOT 1
- WIL github new issue should have category chooser
- wil should have a AdaptFixedSizeToAllocatedResult for non-string types
- THROW_WIN32_IF_MSG / THROW_WIN32_IF_MSG doesn't exist. HOT 1
- wil::GetFinalPathNameByHandleW suggestion HOT 2
- GetCurrentProcessExecutionOption should allow a process name to be passed in HOT 1
- unique_mutex : can't find how you pair closehandle on mutex in WIL HOT 4
- Add a string literal marker for wil::zwstring_view
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wil.