|
Yeah, STL is highly optimised. And highly used....
==============================
Nothing to say.
|
|
|
|
|
STL's map is implemented as a tree, which isn't as fast as hashing. MFC's CMap... classes and STL's hash map use hashing, so should be used if speed is the top goal.
"Microsoft -- Adding unnecessary complexity to your work since 1987!"
|
|
|
|
|
Hi,
is it possible to call web service from java script? if so how to call. please provide me answer
|
|
|
|
|
You should try this link. [^]
Every new day is another chance to change your life.
|
|
|
|
|
You do realise this is a C++ group, with a strong bias to MFC?
There is a java and a javascript forum on codeproject too.
Good luck,
Iain.
I am one of "those foreigners coming over here and stealing our jobs". Yay me!
|
|
|
|
|
Hi,
I have a CWinThread::run overidable that is generating a division by zero at a call to IsIdleMessage which I cann't for the life of me figure out why
Any insight is appreciated
<pre lang='cpp'> int SockCLeintThread::Run()
{ ASSERT_VALID(this);
MSG m_msgCur;
// for tracking the idle time state
if (!flags.is_connected)
return TRUE;
BOOL bIdle = TRUE;
LONG lIdleCount = 0;
// acquire and dispatch messages until a WM_QUIT message is received.
for (;;)
{ phase1: // check to see if we can do idle work
while (bIdle && !::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE))
{ // call OnIdle while in bIdle state
if (!OnIdle(lIdleCount++))
bIdle = FALSE; // assume "no idle" state
} // phase2: pump messages while available
do { // pump message, but quit on WM_QUIT
if (!PumpMessage())
return ExitInstance();
// reset "no idle" state after pumping "normal" message
<b>if (IsIdleMessage(&m_msgCur))<=== code causing exception </b> bIdle = TRUE;
lIdleCount = 0;}
} while (::PeekMessage(&m_msgCur, NULL, NULL, NULL, PM_NOREMOVE));
}
ASSERT(FALSE); // not reachable
} </pre>
|
|
|
|
|
have you overridden IsIdleMessage ?
|
|
|
|
|
|
Why are you overriding CWinThread::Run() anyway? I don't see anything in your code that would require you to do this.
|
|
|
|
|
I am overriding it because I want to use PostthreadMessage and am using the code to create aa mesaage queue
|
|
|
|
|
Hi,
All my exceptions Were occurring in CWinThread::Run Being an Assembler programmer I went into Assembly mode to try and debug it
However the optimizer made things crptic
I then proceeded to use the #pragma to turn off optimization after doing this however the exceptions disappeared
Thanks Again
|
|
|
|
|
You don't have to override Run() to use PostThreadMessage() , and you also don't have to manually create a message queue.
|
|
|
|
|
Hello!
In my current project I'd like to have some additional std::string functions, like trim[r/l], to_lower/to_upper, split and stuff like that.
I know that inheriting from std::string borders on heresy, but I am not sure what else I should do.
I could make a file like strtools.h where all the functions I want are defined but that does not fit the OO scheme of std::string and C++ in general.
Or I could make a class that does not inherit from std::string but privately uses a variable of that type. That would obey OO rules but it's heck of a lot work to do and I guess there will be some overhead (I haven't tested it yet, so hopefuly you can tell me)
What would you recommend me to do and why?
Thanks in advance. ![Smile | :)](https://www.codeproject.com/script/Forums/Images/smiley_smile.gif)
modified 31-May-12 9:29am.
|
|
|
|
|
i usually do it with global (non-class) functions. it's cleaner than going through all the ridiculous hassle of extending std::string.
|
|
|
|
|
Be sure to look at Boost String Algorithms Library[^]. It already does what you want, and even if you don't want to use it directly, there is a lot to learn from there.
|
|
|
|
|
Good suggestion! ![Thumbs Up | :thumbsup:](https://www.codeproject.com/script/Forums/Images/thumbs_up.gif)
|
|
|
|
|
Write a set of free functions that take const string references and spit out strings modified the way you want. There are a couple of observations here...
First one is that just because a function isn't a member of a class doesn't mean that it violates some great principle of OO. A free function can be as much a part of a class's interface even if it's not a member:
class A
{
public:
A &operator+=( const A &add_to );
};
A operator+( const A &a, const A &b )
{
A temp( a );
temp += b;
return temp;
} In this example the freestanding operator+ is very much part of A's interface. As is the usual practice of declaring an insertion and/or extraction operator to do input or output:
class B
{
public:
friend std::ostream &operator<<( std::ostream &str, const B &print_me );
friend std::istream &operator>>( std::ostream &str, const B &load_me );
}; Second one is that C++ isn't just an OO language. OO is probably the dominant idiom but even hardcore OO programmers use a fair number of generic techniques e.g:
std::string to_upper( const std::string &source )
{
std::string upper_case( source.size(), 0 );
std::transform( begin( source ), end( source), begin( upper_case ), toupper );
return upper_case;
} and:
std::string &to_upper_in_place( std::string &upper_case_me )
{
std::string temp = to_upper( upper_case_me );
std::swap( temp, upper_case_me );
return upper_case_me;
} They're both free functions but the second works very much like you'd defined a member of std::string.
Anyway, I've gone on enough. The points I was trying to make are:
- free functions can be part of a class's interface
- if a class hasn't been built to be extended by inheritance (which std::string isn't) then you have to use free functions to extend it
modified 31-May-12 12:40pm.
|
|
|
|
|
|
This is better than some of the articles we see on here. How about posting this into Tips & Tricks for the benefit of the community as a whole?
|
|
|
|
|
I'll have a crack at that over the weekend, thanks for the suggestion.
|
|
|
|
|
Hello Experts,
I want to know how to create a Remote desktop Application in Visual C++ 6.0 (i.e in MFC),I have good knowledge in MFC,but I need to create my own program.
Is there any chance I can create it using C++
Please let me know.
Regards
Kiran
|
|
|
|
|
Please explain what you mean by "Remote desktop Application"?
|
|
|
|
|
Member 9052985 wrote: Is there any chance
Doesn't seem like there's much.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
If you have "good knowledge in MFC", then you should already know what you can do in C++.
In order to create a remote desktop app, you need to know a few things:
0.Sockets (maybe secure sockets while you're at it).
1.Server-client applications.
2.Screen capture methods.
3.Mouse/keyboard capture methods (and the inverse, how to transmit the captured keys).
Can you do it in C++, literally, no... you have to use APIs that are OS dependent... but that's just a technicality, so yes.. you can do it in C++ (with proper use of APIs).
|
|
|
|
|