|
fordge wrote:
suppose i have a map m;
if i need to search for the location using the int data im currently doing
map::iterator iter;
for(iter=m.begin(); iter !=m.end(); iter++)
{
if(iter->second == 10)
break;
}
can i replace this with something like this
iter = find_if(m.begin(),m.end(),bind2nd(KeyEquals(),10));
in which case what would the KeyEquals function object be like???
Sure you can in some way. But why would you want to do this? You have a simple, maintainable solution. Why replace it with a geek-style, Boost-ish hack?
|
|
|
|
|
in this case it may be geekish yes..but i still find it more readable
but there may be more generic adapters where it would be better to use something other than that while loop
also most of the bind1st n bind2nd articles deal only with vectors
and was finding it hard to reproduce the same on maps and sets
anyway here is the solution i got from a fellow coder
typedef std::map MyMap;
bool KeyEquals(MyMap::value_type value, int DataValue)
{
return value.second == DataValue;
}
std::string blah(MyMap const& theMap, int thing)
{
MyMap::const_iterator it =
std::find_if(theMap.begin(), theMap.end(),
std::bind2nd(std::ptr_fun(KeyEquals), thing));
return (it==theMap.end())?std::string():it->second;
}
|
|
|
|
|
say i have a data that i should be able to lookup using EITHER a int key or a string key..i repeat EITHER..
what kind of container should i be using
|
|
|
|
|
<a href = "http://www.boost.org/libs/multi_index/doc/index.html" rel="nofollow">boost::multi_index_container</a>[<a href = "http://www.boost.org/libs/multi_index/doc/index.html" target = "_blank" rel="nofollow">^</a>]
|
|
|
|
|
markkuk wrote:
boost::multi_index_container[^]
... and tell us if you get it started
|
|
|
|
|
Currently created a dialog-based project and then populate it with Text Box controls. My problem is that the dialog stops accepting controls when the total number of control is 255. Is there a way to increase the number of controls beyond 255? Already tried putting edit, group box, etc. but still is limited to 255 maximum.
|
|
|
|
|
Create the controls at runtime. The limit is only with the dialog editor, not with Windows.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I'll try it. Thanks alot.
|
|
|
|
|
Hi,
I dont know
How to make the function hooking on the function like OnOK(), and Other function that was created by you....
I had known used the SetWindowsHookEx with GETTEXT,SETTEXT...
Thanks in advanced
|
|
|
|
|
I have over 200 projects. Many of them are dependnet upon each other in the case of included .LIB files. Is there already a tool that can generate a tree, graph, or even a text listing of the dependencies?
|
|
|
|
|
The File view in the workspace should list out all the dependencies..
This u can c in the visual studio IDE itself.
hope this will help
Zxczc
|
|
|
|
|
Thank you. I can not open each project in the workspace. The idea is to build an automated tool to scan and return information about module dependencies.
I am assuming the #import directive is not being used (else I would have to scan source code as well).
We have over 200 projects and it is difficult to document if a devleoper creates or modifies dependencies. So we want a tool to do it.
|
|
|
|
|
Hi,
I'm trying to create a dialog without creating a resource with all of the buttons for it. How is it normally done using code only? Any reference to a tutorial? I'd prefer using MFC. Obviously people used to do it using Win32, but I don't want to spend too much time on this.
What I'm trying to do is basically write some code for debugging and package it and then import it into my projects easily. So I'll create a modeless dialog with an edit box, then define some global function such as DEBUGPRINT() to write into this dialog. Having to create a resource would make it harder to add to projects.
Thanks.
|
|
|
|
|
You can create dialogs without resources by using the DLGTEMPLATE and DLGITEMTEMPLATE structures with the CDialog::InitModalIndirect or CDialog::CreateIndirect functions.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
Hi, I'm searching for a GUI Builder for Visual C++ 6 (no .NET or MFC). I mean drawing and putting the widgets, and the builder will generate all the code needed, like the WindowBuilder Pro for Smalltalk.
Anyone knows such tool for VC++ ?
regards
|
|
|
|
|
I want to use callback function and want to do it in OO way.
Can some1 plz tell me how to use callbacks in classes. I have done with using the static function. Some1 plz tell me using the non-static method.
|
|
|
|
|
Its not normally possible to provide a callback on a non static member function. The nearest way i know of is to pass the object pointer that the callback needs to be called on as the optional parameter to a callback. this then gets cast back to the correct object type in the static version of the function which then calls the non-static version on the pointer.
If you vote me down, my score will only get lower
|
|
|
|
|
|
See here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi all,
I have a customer reporting a crash in one of my apps. The crash address leads me to believe my program is passing an invalid value to FileTimeToSystemTime() (in kernel32.dll). That should be easy enough for me to verify and fix (famous last words :-p), however I'd like to be able to reproduce the problem before putting blind faith into a fix I can't test on my own.
I'm suspecting he (the customer) has a file somewhere with an invalid date, and my app is retrieving that datestamp and blindly passing it along to FileTimeToSystemTime(). How can I force the creation of file with an "invalid" date? I tried creating a file, then calling SetFileTime() with "invalid" parameters--however it doesn't report any error (it returns TRUE) when I provide it three FILETIME structures that contain zeroes (NOT NULL pointers, which are valid), yet according to Explorer, the file's timestamps aren't changed at all.
I remember seeing files with timestamps of 1/1/1601 on an NTFS partition, and I'm suspecting this is the sort of thing my program is currently choking on.
Can anyone intentionally cause FileTimeToSystemTime() to crash (presumably, by providing it with invalid parameters)?
|
|
|
|
|
I'm thinking that it's going to be difficult to intentionally create a file with a bogus date.
Would it be easier to create a "debug" version of your application that logged the file dates? Then you can inspect the file for any weird numbers.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
That's my impression too.
I'm going to try to get more info out of this guy's system rather than try to replicate some unknown on my end...
|
|
|
|
|
Hello!
I have CEdit control which should receive symbols of several languages simultaneously. In other words, the user should enter, for example, russian and german characters in the same CEdit control. But I can't enter german unlauts when regional settings are not German. Why? What should I do?
My application is compliled with UNICODE support (#define _UNICODE).
Any ideas?
|
|
|
|
|
Maybe Set a ComboBox with languages you want supported... And when selected change the regional settings of ur CEdit to what the language is?... I dont know, ive never done anything with any other language support other then english... Just an idea?
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
The problem probably comes from the fact that the font you are using for your dialog box is not Unicode... In your resources, for that dialog, select the font to be Arial Unicode MS.
You could also do this programmatically...
|
|
|
|