|
There is no general answer to your question.
Actually, you should not even ask the question because the "if (iterator)" should not generally compile. However, in your case, the magic of typedef's probably makes it valid and equivalent to "if (pointer)".
Also, the "suggestion" to do "if ( iterator == container.end() )" is NOT a suggestion: it is the only valid way to check for iterator validity.
my 2 cents...
Guy Prémont
|
|
|
|
|
DevendraC wrote:
I still want to know which overloaded function of iterator is called
when we write:
if(iterator)
Set a breakpoint on that if statement, and step into the line (F11) and you'll see.
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Hi
I want to be able to dump a map out to any stream, ie cout, fstream, or stream into another class (the other class has the << overloaded) but I can't even pass cout into the template. I've cut the code back to the following....
typedef map<string , string> myMAP;
class MyClass
{
private:
myMAP somedata;
public:
void LoadSomeData(T &t) {
template <typename T>
void DumpSomeData(T &t);
};
template <typename T>
void MyClass::DumpSomeData(T &t)
{
myMAP::const_iterator iter(somedata.begin());
while (iter != somedata.end())
{
t << "#" << iter->first << "#" << iter->second << endl;
iter++;
}
}
and to call it I use...
MyClass LoadAndDump;
LoadAndDump.LoadSomeData();
LoadAndDump.DumpSomeData(cout); <-- compiler errors....
It won't compile and gives
error C2893: Failed to specialize function template 'void __thiscall MyClass::DumpSomeData(T &)'<br />
With the following template arguments:<br />
'class std::basic_ostream<char,struct std::char_traits<char> > *'
Any help much appreciated.
Regards
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Are you using MSVC++ 6.0? This compiler is notoriously ill-behaved when dealing with member function templates. Though I'm not 100% sure, sometimes moving the definition to the declaration of the class helps:
class MyClass{
...
template <typename T<
void DumpSomeData(T &t)
{
}
...
};
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Yes - using MSVC++ 6.0, and yes, moving the definition to the declaration works a treat.
Many thanks Joaquin
Angel
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
Hello,
Things only seem to get stranger everyday.
If I am not mistaken, in an ATL ActiveX Control, the aim of FinalConstruct is that by the time the program reaches there, the object has alreay been created.
however that does not seem to be the case.
In FinalConstructor() m_hWnd in the next statement is NULL.
CWnd* parent = CWnd::FromHandle(this->m_hWnd);
How can the control's window not exist after the constructor has been completed?
Placing the same statment in the OnDraw function works, but not in FinalConstruct()?
Am I missing something? Is there some sort of FinalNoReallyThisOneIsTheFinalConstruct() ?
Thanks
|
|
|
|
|
greekgoddj wrote:
How can the control's window not exist after the constructor has been completed?
Because the C++ object and the window have different lifetimes. The C++ object is created before the window is. FinalConstruct() is, as the name implies, part of the construction process, so only the C++ exists when it is called.
--Mike--
LINKS~! Ericahist updated! | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Try trapping the WM_CREATE message. Or WM_INITDIALOG if you're using a dialog based window.
--
My name in Katakana is ヨルゲン.
My name in German is Jörgen.
I blog too now[^]
|
|
|
|
|
Yup....the solution is...
LRESULT CKnob::OnShowWindow(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)
Thats where the window is already created and ready. Needed to overide that and add my code inside there.
Thanks!
|
|
|
|
|
In virtula method FinalConstruct() is control created in sense of com object. Creation of control (window) is performed in method OnCreate(...) (this is message handler of message WM_CREATE like in common window).
|
|
|
|
|
hi,
i got an add-in that creates new .cpp and .h file with templates in them.
i want that after i save the files in the project to get them into the VSS.
how can i do that?
(EnvDTE.SourceControl only got checkout functions...)
Avi.
|
|
|
|
|
|
thanks man,
but i didn't find there an answer to my question...
can u direct me further more?
|
|
|
|
|
How can i move the bottom element in an array to the top,
From
Name 1
Name 2
Name 3
to
Name 3
Name 1
Name 2
can anyone help
|
|
|
|
|
I am writing an add-in for Visual Studio .NET 2003 on Windows XP SP2 that will display a dialog with a list control. However when I build the solution, I get 4 linker errors saying that some functions e.g. SetItemColor cannot be found. I have included the path to the WTL files in the properties section of the solution.
Anybody with an answer?
I am the handsome one in the crowd.
|
|
|
|
|
I have an ATl ActiveX control I am writing which has support for MFC. I want to add a CEdit in my control so that the user can enter values. How do I create this?
I have spent all yesterday (literraly) trying and no luck.
I construct by
CEdit myEdit;
Followed by
CWnd* parent = CWnd::FromHandle(this->m_hWnd);
myEdit.Create(ES_CENTER | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
CRect(10, 10, 100, 40), parent, 1);
This causes assertion...I cannot even find or understnad where the assertion is caused as when i look at the call stack in the debugger, there are no comments or ASSERT(...) around.
Has anybody sucessfully added a CEdit to an ATL ActiveX control which supports MFC? If so...how?
Thanks
|
|
|
|
|
Well...finally got this one figured out.
Must add [code]AFX_MANAGE_STATE(AfxGetStaticModuleState());[/code] before [code]CWnd* parent = CWnd::FromHandle(this->m_hWnd);
myEdit.Create(ES_CENTER | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER,
CRect(10, 10, 100, 40), parent, 1);[/code]
Ciao
|
|
|
|
|
Sorry,I tried this,but still can't work,IE crashed and error is "Debug Assertion Failed"
|
|
|
|
|
Can any one tell me how to check EOF/BOF status in a rowset?
Lisoft
|
|
|
|
|
Hey i had the same problem. Well there is no EOF or BOF.
Check for S_OK as till S_OK is returned EOF is not reached.
i solved it using that.
Gaurav Jain
K.K. Wagh Institue of Engineering Education and Research,
Nashik,
Maharashtra,
India.
gauravjain911@yahoo.com
|
|
|
|
|
I also found the OLE DB consumer templates does not have the EOF/BOF status like the ODBC(MFC) class which I used to access the database before. When CRowset class was first initialized by CCommand::Open method, the 'cursor' does not point to the first record like the ODBC(MFC) class. The only way to check if there is anything returned from the database is to call CRowset::MoveNext() method and check the return value to determine EOF status.
Anyway, thanks for your help.
Lisoft
|
|
|
|
|
Hallo,
I need please help to pass string from a dll to an nt service.
I’m also interesting in a way to pass string from a service (c++) to a vb application that not runs a form.
Thanks a lot for helping
dabayi
|
|
|
|
|
I am trying to write a application with string dialog resources in 2 languages(En and De). SetThreadLocale works fine in XP system, but not in 98.
How should i do to load and display an De dialog on 98 system
|
|
|
|
|
At me such problem:
When the standard page of properties (Property Page) is created - that everything is all right,
And when I try to create it manually - it is not displayed.
I hands finish such in CoClass.h:
BEGIN_PROP_MAP (COpenGL)<br />
PROP_DATA_ENTRY ("_cx", m_sizeExtent.cx, VT_UI4)<br />
PROP_DATA_ENTRY ("_cy", m_sizeExtent.cy, VT_UI4)<br />
PROP_ENTRY ("FillColor", DISPID_FILLCOLOR, CLSID_StockColorPage)<br />
<br />
PROP_ENTRY ("Dialog", 2, CLSID_PropDlg)
<br />
END_PROP_MAP ()
And in a result the Property Page created in manual is not displayed (and that standard "FillColor" - is displayed)......... (are displayed only standard - FillColor, and one more)
What to make, that it worked?
And all over again I received the message, that CLSID_PropDlg is in general a unknown piece (but then itself has passed)
That I receive in a idl-file:
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\prsht.idl";
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\mshtml.idl";
import "e:\program files\microsoft visual studio .net 2003\vc7\platformsdk\include\dimm.idl";
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\mshtmhst.idl";
import "e:\program files\microsoft visual studio .net 2003\vc7\platformsdk\include\docobj.idl";
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\exdisp.idl";
import "E:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\PlatformSDK\include\objsafe.idl";
[
object,
uuid(BB2EEEBB-B474-4CBC-9B70-697E4ECC1EE8),
dual,
helpstring("IOpenGL Interface"),
pointer_default(unique)
]
#line 49 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
interface IOpenGL : IDispatch {
#line 52 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
[propput,bindable,requestedit,id((-510))] HRESULT FillColor([in] OLE_COLOR clr);
#line 54 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
[propget,bindable,requestedit,id((-510))] HRESULT FillColor([out,retval] OLE_COLOR *pclr);
[id(1),helpstring("method GetLightParams")] HRESULT GetLightParams([out] int *pPos);
[id(2),helpstring("method SetLightParam")] HRESULT SetLightParam([in] short lp, [in] int nPos);
[id(3),helpstring("method ReadData")] HRESULT ReadData();
[id(4),helpstring("method GetFillMode")] HRESULT GetFillMode([out] DWORD *pMode);
[id(5),helpstring("method SetFillMode")] HRESULT SetFillMode([in] DWORD *nMode);
[id(6),helpstring("method GetQuad")] HRESULT GetQuad([out] BOOL *bQuad);
[id(7),helpstring("method SetQuad")] HRESULT SetQuad([in] BOOL bQuad);
};
[ version(1.0), uuid(4CA16C3B-D4B6-434D-9648-2E419FF79F15), helpstring("ATLGL 1.0 Type Library") ]
library ATLGL
{
importlib("stdole2.tlb");
importlib("olepro32.dll");
[
uuid(9D2FB6B9-6797-45D0-A331-A6DE808F9A82),
helpstring("_IOpenGLEvents Interface")
]
#line 72 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
dispinterface _IOpenGLEvents {
properties:
methods:
};
[
version(1.0),
uuid(35435006-DA95-4B34-9988-5A0A512E3F3C),
helpstring("OpenGL Class")
]
#line 88 "d:\\d\\c7\\com\\atlgl\\atlgl\\opengl.h"
coclass COpenGL {
interface IOpenGL;
[default, source] interface _IOpenGLEvents;
};
[
version(1.0),
uuid(F2FBEB23-A2C0-4C9D-B049-6E14D8A3E8CF),
helpstring("PropDlg Class")
]
#line 19 "d:\\d\\c7\\com\\atlgl\\atlgl\\propdlg.h"
coclass CPropDlg {
[default] interface IUnknown;
};
[
version(1.0),
uuid(CD2867E6-F4C7-48A6-8D06-D1856D501B2E),
helpstring("tMy Class")
]
#line 19 "d:\\d\\c7\\com\\edf\\atlgl\\tmy.h"
coclass CtMy {
[default] interface IUnknown;
};
}
|
|
|
|
|
Do not pay attention to this post, I have already found a mistake
|
|
|
|