|
It works exactly the same as if you had two instances of a non-templated class.
The template code bloat is that the compiler needs to generate new classes for each DIFFERENT template parameter it is used with.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
|
It is the linker's responsibility to strip off duplicates across compilation units, so in general there'll be only one implementation.
Code bloat can stem from another reasons:- instantiating
vector s (or other template classes) of many different types
- code bloat resulting from massive inlining
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
code bloat resulting from massive inlining
Although I'll point out that inline is a suggestion to the compiler, not a command. If you inline stupidly, the compiler will ignore you.
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
How can I get the WebPage's Last Modified Time.
Following is my code,but it doesn't work properly.
::HttpQueryInfo always return FALSE. Why?
BOOL CChkOlDlg::IsUrlModified(CString strUrl)
{
BOOL bRet = FALSE,bSucc = FALSE;
HINTERNET hSession ;
hSession = ::InternetOpen(_T("CheckOl"),
PRE_CONFIG_INTERNET_ACCESS,
_T(""),
INTERNET_INVALID_PORT_NUMBER,
0 ) ;
if(hSession)
{
HINTERNET hConnect = ::InternetConnect(hSession,
GetServer(strUrl),
INTERNET_INVALID_PORT_NUMBER,
"",
"",
INTERNET_SERVICE_HTTP,
0,
0);
if(hConnect != NULL)
{
HINTERNET hHttpFile = ::HttpOpenRequest(hConnect,
_T("GET"),
strUrl,
HTTP_VERSION,
NULL,
0,
INTERNET_FLAG_DONT_CACHE,
0) ;
if(hHttpFile != NULL)
{
BOOL bSendRequest = ::HttpSendRequest(hHttpFile, NULL, 0, 0, 0);
if(bSendRequest)
{
char bufQuery[32] ;
DWORD dwLengthBufQuery = sizeof (bufQuery);
BOOL bQuery = ::HttpQueryInfo(hHttpFile,
HTTP_QUERY_LAST_MODIFIED,
bufQuery,
&dwLengthBufQuery,
NULL) ;
if(bQuery)
{
bSucc = TRUE;
}
}
VERIFY(::InternetCloseHandle(hHttpFile));
}
VERIFY(::InternetCloseHandle(hConnect)) ;
}
}
if(!bSucc)
{
}
return bRet;
}
|
|
|
|
|
Possibly because web servers rarely send out the last modified information in the header of an HTTP response.
Test this with telnetting to your host on port 80 and issueing your GET (or HEAD) request manually. Is the info there?
Sorry to dissapoint you all with my lack of a witty or poignant signature.
|
|
|
|
|
Other Severs don't work also.
I use HTTP_QUERY_DATE and HTTP_QUERY_VERSION, ::HttpQueryInfo works OK.
Using HTTP_QUERY_CONTENT_LENGTH,::HttpQueryInfo return a wrong size of the page.
Using HTTP_QUERY_LAST_MODIFIED,::HttpQueryInfo doesn't work.
|
|
|
|
|
C:\Windows\Desktop\Project2\Project.cpp(383) : error C2679: binary '<<' : no operator defined which takes a right-hand operand of type '' (or there is no acceptable conversion)
Error executing cl.exe.
here is the code!
ostream& operator << (ostream& s, Market& market)
{
for(int i = 0; i <10; i++)
{
s <<"Stock information: "<< market.stockArray[i].getCompanyName()<<" "<<market.stockarray[i].getstockticker()<<" "<<market.stockarray[i].getmarkettraded()<<"="" "<<market.stockarray[i].gettypeofmanufactr()<<"="" "<<market.stockarray[i].getinitialvalue()<<"="" "<<market.stockarray[i].getnumofoutshares<<endl;
="" return="" s;
="" }
}
<\pre="">
thanks
|
|
|
|
|
takes a right-hand operator of "... what?
Presumably one of the items you're trying to push into the stream is not a basic type, or is of a type that doesn't have << defined.
Try breaking your statement up a bit and you should find out which one is causing the problem:
s << "Stock information: ";
s << market.stockArray[i].getCompanyName();
s << " ";
etc...
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
This code cannot work. How can you have a loop, and return s in the first iteration ?
Anyhow, this code has some other issues. First of all, you need first to check the stream state. Second of all you need to create a sentry instance to perform prefix and postfix operations. Lastly, this code will not work with formating operators. The way I do it is to stream my data to an ostringstream, then pass it in one go to the ostream passed in. Here is an example
template<class chart,="" class="" traits="">
std::basic_ostream<chart, traits=""> &
operator << (std::basic_ostream<chart, traits=""> & os, const RECT & rc)
{
//Check stream state first
if (!os.good()) return os;
// Create sentry for prefix operations ( it's destructor will carry out postfix operations )
typename std::basic_ostream<chart, traits="">::sentry opfx(os);
if (opfx)
{
std::ostringstream str;
str << "left: " << rc.left;
str << " right : " << rc.right;
str << " top : " << rc.top;
str << " bottom : " << rc.bottom;
str << " width : " << rc.right - rc.left;
str << " height : " << rc.bottom - rc.top;
os << str.str().c_str();
}
return os;
}
Christian
I have come to clean zee pooollll. - Michael Martin Dec 30, 2001
Picture the daffodil. And while you do that, I'll be over here going through your stuff.
|
|
|
|
|
How do I intercept the command "net send" to remove the name of the user that did the sending in the remote pc's dialog box.
By this i mean somehow finding the HWND of that window and dynamically changing the text at the top of the dialog before
it is sent via a socket
-
|
|
|
|
|
How about this?
HWND hWnd;
HWND hStatic;
hWnd = ::FindWindow(NULL, "Messenger Service ");
if (hWnd)
{
hStatic = ::FindWindowEx(hWnd, NULL, "Static", NULL);
}
Cheers,
/Fredrik
Sonork ID: 100.11430:PhatBoy
|
|
|
|
|
Is it bad programming practice to use properties in your ATL components.
I mean which of the two is better :-
(1) Function(arg1, arg2, arg3)
(2)
arg1=100
arg2=100
arg3=200
Function()
The reason why I'd like to use properties is that I am planning to write some components for use from ASP. And the normal ASP/VB way is to use properties, I think so anyway.
Any ideas or suggestions on this are appreciated.
Thanks in advance.
Nish [ATL newbie]
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
I would say (and, to state again, this is only MY opinion)...
Only use a property if:
a) It is going to be persistent (stored with the object) or
b) It is used in more than one method in the object.
Use parameters if the values are only going to be used in that method, otherwise you're incurring the penalty of making COM calls for each parameter and then the method as well.
So, I think you can read that as suggesting parameters.
Also, in ASP you can quite happily use parameters, just like a Sub.
MyObject.MyMethod "Parameter 1", viParameter2, "Some Other Parameter"
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
Derek Waters wrote:
Use parameters if the values are only going to be used in that method, otherwise you're incurring the penalty of making COM calls for each parameter and then the method as well
Thanks a lot Derek. That was very useful.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
With properties your component acquires state, so maynot scale well when deployed in MTS where Just in Time activation and ASAP deactivation help in improving throughput. Also if the components are deployed in remote machine or as out of proc components, look at the extra marshalling, network calls.
|
|
|
|
|
Thanks Ravish.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
It is fine if you plan to use stateful programs.
If eventually, your app and the number of components grow
Using properties vs just methods or functions with parameters will slow down the application.
Using properties
1) More Overhead is created marshalling the asp - com calls
2) Limited threads in IIS are consumed longer by stateful components
3) There is an increase in RPC calls if dcom is used
Do you think you could solve my problem?
http://www.codeproject.com/script/comments/forums.asp?forumid=1647&select=114120&tid=114120#xx114120xx
Safearray and COM+
|
|
|
|
|
Thank you.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
How can i change application icon dinamicaly?
|
|
|
|
|
If using MFC: CWnd::SetIcon
/moliate
|
|
|
|
|
Icon must be stay changed after close application (In Explorer - another icon).
|
|
|
|
|
You cant change your exe file's icon dynamically. You'd have to recompile it with a new icon. Unless you figure out some way to open the file and overwrite the icon with a new one.
Nish
Nish was here, now Nish has gone;
He left his soul, to turn you on;
Those who knew Nish, knew him well;
Those who didn't, can go to hell.
I like to on the Code Project
Sonork ID 100.9786 voidmain
www.busterboy.org
|
|
|
|
|
To do so, you would need to update you main icon resource. If this is what you're after, you might want to check out:
BeginUpdateResource()
UpdateResource()
EndUpdateResource()
on MSDN. You'll need to use them to change your icon dynamically.
------------------------
Derek Waters
derek@lj-oz.com
|
|
|
|
|
That is a lot harder. May be impossible. A possible solution might be to spawn a new process when the application is about to terminte. The process kills its parent, opens the parents .exe file, finds the icon and replaces it before terminating.
I really don't know if it will work. If the iconswapping is critical for your application you might give it a shot. As Derek pointed out you can use the resource function set.
/moliate
|
|
|
|