|
It's always a mess to get const ness right with functors. The correct implementation is:
class DeleteValue : public std::unary_function<std::pair<int const,char *>&, void>
{
public:
void operator()(std::pair<int const,char *>& pairObject)
{
delete [] pairObject.second;
}
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Off-topic question here, but why do you need unary_function as a base class? And how does the base relate to the operator() ? I thought the operator() , with the correct signature of course, was what made the class a functor.
--Mike--
Thing #9 to say when mad at work: "Therapy is expensive. Popping bubble plastic is cheap. You choose."
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Actually, unary_function is not strictly needed. It is a shortcut to get argument_type and result_type inner types defined, which can be useful when doing metaprogramming. For instance, consider the following composite operator:
template <class func1_type,class func2_type>
struct composite: public unary_function<func2_type::argument_type,func1_type::result_type>
{
composite(func1_type f1=func1_type(),func2_type=func2_type()):f1(f1),f2(f2){}
func1_type::result_type operator()(func2_type::argument_type a)
{
return f1(f2(a));
}
private:
func1_type f1;
func2_type f2;
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
*scratches head*
See now, this is one of those times where STL makes my head hurt.
--Mike--
Thing #9 to say when mad at work: "Therapy is expensive. Popping bubble plastic is cheap. You choose."
Just released - 1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Once you get used to STL, it is like speaking German --one has a lot of fun just getting the syntax right.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sort of like stomping on an open box of needles. Once you get use to it, it is fun.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
|
By default, class factory create a new object for every request, this is not good when a application that should using a COM object as global var. I don't understand ATL deep, so how to modify class factory of special COM object?
|
|
|
|
|
Follow the thread of DECLARE_CLASSFACTORY_SINGLETON through the documentation.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
|
I'm looking for a good how-to book and a good reference (in-depth) book for ATL in VS.NET. (ATL 7?)
Thanks.
-Sean
----
Only two things are infinite, the universe and human stupidity, and I'm not sure about the former. -- Albert Einstein.
I saw a woman wearing a sweatshirt with 'Guess' on it. I said, "Thyroid problem?" -- Emo Philips.
Love is two minutes, 52 seconds of squishing noises. -- Johnny Rotten.
|
|
|
|
|
Reasonable Developer
i wanted to download the SDK of Microsoft Project, i try my best but fail(it give overview of MS Project 2002) pls help me. So nice of u
Note
i have already test it but it was just an overview of sdk whereas i have to integrate the MS Project & therefore i need to download the complete sdk, now pls try for it & if u find any solution inform me
So nice of u OK
|
|
|
|
|
Please do not cross post.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
I'm just about to start a new ATL COM Service using VS.NET. I'm wondering if there are any advantages to using an attributed ATL Service or whether it is more hassle than it is worth?
Anybody used it and care to share their insights.
Michael
Life’s not a song.
Life isn’t bliss.
Life is just this.
It’s living. -- Buffy the Vampire Slayer: Once more, with feeling
|
|
|
|
|
Use attributes whenever you want to lock your code and get nobody to be able to recompile it !
Seriously, i believe there are good and bad things about it :
- good, separate IDL files are in fact not needed. Using attributes is a complement of ATL macros, and can produce COM services with fast and effective code. In an ideal world, ATL macros would have even been made obsolete thanks to the attributes, but it looks like VS.NET 1.0 is a product in the middle of something.
- good, attributes open new business opportunities for software companies. We have yet to see such products, though. Think about intellisense support for instance.
- bad, no debugging support.
- bad, attribute style is proprietary. Attributes may change between 2 VS.NET releases (forces you to upgrade your code).
|
|
|
|
|
Thanks,
.S.Rod. wrote:
- bad, no debugging support.
Well that pretty much sealed it for me. I'll steer clear of attributes for the moment.
Michael
Life’s not a song.
Life isn’t bliss.
Life is just this.
It’s living. -- Buffy the Vampire Slayer: Once more, with feeling
|
|
|
|
|
I'm no expert, but I've been playing around with attributes and there is debugging support. The attribute injected code is referenced in the pdb (debug) file when you do the build.
In addition with a compiler switch /Fx it will show you all the code that it is injecting by placing it in a separate file in your project folder.
In fact you can copy the code out of the separate files it generates and put them back into your project in place of the attributes if you want more control over things.
There is an overview article about attributes that might help you make your decision:
http://msdn.microsoft.com/msdnmag/issues/01/04/attributes/default.aspx[^]
|
|
|
|
|
Example one:
I create custom (dialog based) toolbar. CMainFrame winproc eats up RBN_AUTOSIZE, so my view has resizing problems. Temp Fix NOTIFY_CODE_HANDLER(RBN_AUTOSIZE, ...) at the beginning of the message map.
Example two:
on a property page (CPropertyPageImpl) I try to create owner drown combo. CPropertyPageImpl winproc eats up WM_DRAWITEM for the edit part. Fix is similar to intercept WM_DRAWITEM and ::SendMessage(((LPDRAWITEMSTRUCT)lParam)->hwndItem ....
There is obviously something that I am doing wrong in my code that makes WTL/ATL winprocs to eat up the messages. Any ideas?
|
|
|
|
|
Perhaps adding the REFLECT_NOTIFICATIONS() macro to the message map would be helpful.
|
|
|
|
|
done that - does not help
|
|
|
|
|
[
object,
uuid(F7E68672-A712-4BCC-B913-A99CA2396674),
helpstring("IComminucation Interface"),
pointer_default(unique)
]
interface IComminucation : IUnknown
{
[helpstring("Allocate a connect to Mid-ware")] HRESULT AllocaConnect([out, retval] void * p_pclMid); // error line, error message see blow.
};
....
error MIDL2139 : type of the parameter cannot derive from void or void * : [ Parameter 'p_pclMid' of Procedure 'AllocaConnect' ( Interface 'IComminucation' ) ]
|
|
|
|
|
COM does not support void - obvious marshaling problems.
|
|
|
|
|
Why dose QueryInterface suport void*?
|
|
|
|
|
The parameter is void** because you pass in a pointer to an interface (which is itself a pointer). Since QI is designed to return any supported interface, this being typed would be a problem, so void** is the obvious(?) choice for the type.
Anyone else have a devstudio macro that wraps reinterpret_cast<void**>() around the selected word?
Steve S
[This signature space available for rent]
|
|
|
|