|
Your code can't compile...
Thank you for you reply.
|
|
|
|
|
How about abstracting the construction into a function as it's hard to grab the extra level of indirection using a vector constructor or an algorithm:
std::vector<std::set<int>::iterator> build_index( const std::set<int> &s )
{
std::vector< std::set<int>::iterator > index;
for( auto iter( s.begin() ); iter != s.end(); ++iter )
{
index.push_back( iter );
}
return index;
}
int main()
{
int set_initialisers[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
std::set<int> s( std::begin( set_initialisers ), std::end( set_initialisers ) );
std::vector< std::set<int>::iterator > index( build_index( s ) );
} It's not that inefficient in C++98 as it'll probably trigger NRVO and in C++11 it'll use the move constructor for vector.
|
|
|
|
|
Thank you very much!
It does work. You are great!
|
|
|
|
|
Be very careful about using this sort of thing - as others have mentioned it's probable that your design isn't quite what you think it is (for example setting things of multiple types through an interface).
Good luck though and nice to see someone actually using <algorithm> in their work!
|
|
|
|
|
Another question, I have to use std::sort like this:
bool func(set<int>::iterator lhs, set<int>::iterator rhs)
{
return *lhs > *rhs;
}
|
|
|
|
|
Another question, I have to use std::sort like this?
bool func(set<int>::iterator lhs, set<int>::iterator rhs)
{
return *lhs > *rhs;
}
sort(vec.begin(), vec.end(), func);
How can I use
std::copy(vec.begin(), vec.end(), std::ostream_iterator<<big>???</big>>(std::cout, "\t"));
|
|
|
|
|
It is posible to change the style of a CComboBox control from CBS_DROPDOWN to CBS_DROPDOWNLIST on runtime ?
I've tried with ModifyStyle and ModifyStyleEx and doesn't work ...
|
|
|
|
|
Your question is a bit vague...
Of course you can do it at run-time, just create the CComboBox by hand. Then you can set it when you call CComboBox::Create() . If on the other hand, you mean can you change it after you've created the CComboBox , not sure, but do you really need that capability?
|
|
|
|
|
Thank you for your answer, I realise that I thought wrong the program ... I have not create CComboBox control dinamically (with Create), I put it on a dialog, setup manually the style (CBS_DROPWDOWN), and I was wonder if some condition is true, to modify the style on InitialUpdate ...
|
|
|
|
|
Some combobox styles cannot be altered at runtime.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous
|
|
|
|
|
If you're going to do it on InitialUpdate() , then create it dynamically (using CComboBox::Create() ).
|
|
|
|
|
Thanks all for your answers, but as while I have some request, that result that I thought the program in wrong way ... anyway, is a good your ideea, Albert, in case that I need it !
|
|
|
|
|
Even if you create it manually, there is not guaranty that the style can be change after it is created.
Watched code never compiles.
|
|
|
|
|
But he says he has to change it on the initial update... which means he only changes it once based on something, so creating it dynamically should work for him.
|
|
|
|
|
Hi,
I have a derived CAsyncsocket class in a member of my CWinThread Class
"I am trying to have each socket connection run in its own thread"
I am trying to have four threads for four connections
in the ::InitInstance of the CWinthread I get an exception in the CAsynSocket:: create
method My question is is the socket object completly created by the time it hits the
Initinstance of the CWinthread its living in
thanks
|
|
|
|
|
The CAsyncSocket class and the CWinThread class you put it in have little to do with each other by default, when it gets created depends on where you put it. You have to show us your code for us to be able to be more helpful with your issue.
Don't forget you have to call Create() on the socket class to actually create a socket.
http://msdn.microsoft.com/en-us/library/3d46645f%28v=vs.80%29.aspx[^]
|
|
|
|
|
Casynsocket derived is a member of CWinThread dervied I figure by the time it hits ::initinstance it will be created meaning "CAsynSocket" object
going back back to another thread I created regarding exceptions
if implement a catch for a derived CInternetExeption I am assuming CInternetException would catch socket errors
along with having a EnableStatusCallback procedure I be able to get more specfic information on the type of exception I am dealing with do any the create parms have bad ptrs that would be a memory exception or is it internet/socket exception
am I on the right track ??
|
|
|
|
|
As far as the CAsyncsocket... what you said doesn't make much sense... but I'm not sure if it's lost in translation.
|
|
|
|
|
I should re-word my question would would CInternetExcption catch an exception resulting from sockets
thnaks
|
|
|
|
|
I want to recognize tables inside PDF, now I have rectangles of the PDF Text Objecthttp://i.stack.imgur.com/aHK3Q.png(the red rectangles in the picture).I'm confused about how to implement this rectangle algorithm. The programming language what I use is VC++.
What I want to get is:http://i.stack.imgur.com/aPxz1.png
The Result is a perfect table with header, rows, columns.Can anyone help me? How to rectangle table from these rectangles? These rectangles' orginal point (0, 0) is on the bottom-left point. x coordinate grow from left to right, and y coordinate grow from bottom to up.I don't want to use 3rd party. I want to implement this function through rectangle algorithm.
Any help would be greatly appreciated!
|
|
|
|
|
PDF content is held in a codified format inside the file and the information about how to render it to a display device is kept with the data. You can either use one of the many free libraries available on the internet or, if you do not want to use a third-party library, you need to get a copy of the PDF specification from Adobe[^] and write your own handler.
|
|
|
|
|
Hi,
I am basically a MFC newbie my background is MainFrame Assembler and I am begining to feel comfortable writting OO code
my next hurdle is execption processing I have read the documentation and MFC has its own abstract classes for exception handling
The way I am understanding it is as follows an exception is cought by a
catch paragraph.. depeding on the type e.g. for a memory exception I would have to have a derived class of CMemoryException e.g
class Mymemoryexception : public CMemoryException
and do catch (Mymemoryexception *)
If I want more information I would have to register a exception handler
my question is the following what is the scope of the exception handler
is it perthread meaning if the catch paragraph is executing whitin a thread then it
will catch all exceptions for the thread ??
is the scope per object ??
I guess I am hoping somebody can give a better expliantion then the documentation from
MSDN
thanks
|
|
|
|
|
A catch clause will cath the specified exception and any derived exception.
In practice, if you don't write library for others, you rarely have to throw your own exception (and even less to catch them).
Generally you don't have to use exception handler and you should not have too much throw or catch in your code as exception are typically used for things that should not occurs.
MSDN documentation (and Google) are more complete documentation. It is not easy to explain it in a paragraph or two.
MFC and Visual C++ exception handling have some difference with standard C++ exceptions. For example catch ... will catch Win32 exceptions, MFC exceptions are thrown by pointer and exception specification is not implemented.
Philippe Mori
|
|
|
|
|
Somebody will throw the ball and somebody should catch it. So you should know the possibility of piece of code that throws and should decide where to catch and what exactly to catch.
Say, if you place a try and catch block on the main() or Win main, and leave the catch block empty or look for a more generic CException, all the exception can be caught if it is not handled by the called functions. Which is bad in a big application with millions of code.
So define the try..catch to a narrow down piece of code, and catch the specific exception say filenotfound exception should caught from the piece of code that opens a file.
More Info: Exception Handling for C# Beginners[^]
|
|
|
|
|
would it work If I define multiple catchs each with a different exception type
thanks
|
|
|
|