|
Is it possible to send as parameter to template a other template function ?
template< typename T >
T add( const T& a, const T& b )
{
return a + b;
}
template< class T, class O >
void Calculate( T& rlh, const T& rrh )
{
for( int i = 0; i < sizeof( T ); ++i )
{
rlh = O< T >( rlh[ i ], rrh[ i ] );
}
}
and use of Calculate template function
const TVector< TYPE >& operator += ( const TVector< TYPE >& rv )
{
Calculate< TVector< TYPE >, add< TVector< TYPE > > >( *this, rv );
return *this;
}
|
|
|
|
|
The effect you're after can be achieved by means of template template parameters, i.e. parameters of a template declared to be template classes themselves:
template< class T, template <class A> class O >
void Calculate( T& rlh, const T& rrh )
{
for( int i = 0; i < sizeof( T ); ++i )
{
rlh = O< T >( rlh[ i ], rrh[ i ] );
}
} The parameter template <class A> class O is required then to be a template. Note that the particular A used for the declaration is immaterial: it's only there to signal that O is a template. In fact, you can just write it down like template <class> class O . Later in the code you specify the way in which O is to be instantiated (in your example, as O< T > ). Using template template parameters, your operator += is written like this:
const TVector< TYPE >& operator += ( const TVector< TYPE >& rv )
{
Calculate< TVector< TYPE >, add >( *this, rv );
return *this;
} The bad news is that, to the best of my knowledge, MSVC++ does not support template template parameters, so you'll have to look forward to MS guys deciding to put their compiler up to date (maybe VC.NET?).
You might like to go to the Comeau C++ Template FAQ for further info on this and other aspects of C++ templates. Also, a guy named Andrei Alexandrescu is lately doing some amazing things with template template parameters and has just published a book entitled Modern C++ Design: Generic Programming and Design Patterns Applied discussing these techniques. Check the free excerpt available on the book's web site.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi all,
I wanna create setup disk of my program in VC++,
I used of InstallShield in Tools menu in VC++,
In my program i used Crystal Report ActiveX ...
And InstallShield added ActiveX automatically to setup disk, now setup disk is ready and will run in my computer, but when i run it in other computer, windows indicate to me error: "Can not move Cry32.ocx !!!"
So, what is my wrong ??????????????
Please help me ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
I don't have a direct fix for your problem, but try using a different setup program.
http://www.jrsoftware.org/isinfo.htm
The best thing about this one is that its really well documented, and easy to use. Installsheild is frankly a pain.
INOSetup is totaly free. But wait theres more : there are free third party tools to use with this setup program to make your life even easier.
Your problem sounds a little odd. Did the other computer already have a version installed? If so, the setup program should be able to add it to the list of files to be undated on rebooting, if the file was in use. I would not have thought this was the case. What does the docs with Crystal Reports say about redistributing the file? I thought to use CR, you had to install the complete package with your system. So you would need a fully installed copy on the other machine, rather than just a few of its controls.
Giles
|
|
|
|
|
First check the file group Installshield made, make sure the correct files was placed there. Make sure the settings are correct, as in install newer version or date, etc.
If everything seems okay then check the client, make sure the correct file was indeed installed. Make sure it was registered properly.
If you need assistance check www.installsite.org, or Installshield at http://support.installshield.com/
|
|
|
|
|
I have to throw in my two cents on this again.
Lose InstallShield - it's an overpriced, poorly documented piece of crap.
Think about it - they offer training seminars, etc, for a price. Probably a big piece of their business. Do you really feel that an install program should require this level of training? The only reason it does is because it's such a lousy product to begin with.
Use Inno - it is superior to InstallShield in every possible way - not least it's price. Support is available through newsgroups on Jordan's site if needed, but frankly it's so easy to use and so well documented I've never had a problem with it.
I also recommend using TafWeb's 'ScriptMaker' - a 3rd party GUI that makes Inno a real snap to learn and use. There's a link to it on Jordan's site.
Dave R
|
|
|
|
|
it's an overpriced, poorly documented piece of crap.
I'll agree that Installshield is overpriced. However, how can you say it is poorly documented? How many books are published covering Inno? Three that I know of for Installshield and more on the way.
Support is available through newsgroups on Jordan's site if needed
Installshield also has newsgroups and a well maintained information site at www.installsite.org as well as the Installshield support site.
they offer training seminars, etc, for a price
Oracle offers training class for their products, as due many other companies. Is this reason enough to switch? What is the problem with offering training for their own products? I would rather attend a class given by the people who wrote it than some training company employee who read the documentation the night before the class.
using TafWeb's 'ScriptMaker' - a 3rd party GUI that makes Inno a real snap to learn and use.
With Installshield you need nothing else to learn and use the it.
I've said it before on this subject, most opinions of your nature come from one who is uninformed and has not taken the time to learn the tool properly.
|
|
|
|
|
How many books are published covering Inno? Three that I know of for Installshield and more on the way.
I'd say that if anything that just reinforces my point. Personally, I have better things to do with my time than read three books on how to use an installation tool.
Oracle offers training class for their products, as due many other companies. Is this reason enough to switch?
So you compare the complexity of InstallShield to that of Oracle's products?
I've said it before on this subject, most opinions of your nature come from one who is uninformed and has not taken the time to learn the tool properly.
Right. Any opinions that differ from your own are uninformed.
Grow up.
Dave R
|
|
|
|
|
Use Inno - superior to InstallShield in every possible way Your opinion. I did not criticize you for it. Nor did I respond with "grow up". I took some of your arguments and pointed out where you were misinformed.
In your original post you stated that, in your opinion, Installshield was not well documented. I countered by offering evidence that indeed there was a wealth of information available. You countered with Personally, I have better things to do with my time than read three books on how to use an installation tool.
How many books have you read on programming languages? Is Visual C++ "lousy" because you needed to read documentation to get the most from it?
You also stated that you felt Installshield was a "lousy" product because they offerd training in how to use it. I countered by pointing out that Oricale and others do the same. Your implication is that if a company offers training then their product is "lousy".
Again you stated that Inno has a newsgroup and support site and I countered that Installshield has the same offerings.
Right. Any opinions that differ from your own are uninformed. It seems that you embody this statement more than I.
|
|
|
|
|
Please check wheather you are building the setup a Full build or Quick Build, you should use Full build while distrubuting
A
|
|
|
|
|
I would say that the problem is related to an issue involved on trying to copy and then delete the specified file from the source media type. I am saying this based on the error message "Can not move Cry32.ocx".
This usually happens when in the Files tab of InstallShield, your file is a "link" rather than a "copy". Why don't you try first to check this. The problem with a "link" is that InstallShield creates or generates a setup based on a reference link to the file in question rather than a copy from the file itself.
In your computer works because the "link" could be resolved perfectly, but not in another environment, even if the target computer has already installed the Crystal components.
I used InstallShield for some time, and now I have changed to MSI. This is the Windows Installer SDK. It is far powerful than any other installation tool I have seen, because the core is a service of the operating system. That means, that your code could be 100% resilient. This is such a great feature!
On the other hand, it has the install on demand characteristic plus the ability to provide your own UI dialogs.
Well this is my personal point of view, and as always, every one will have their favorite tools, and perspective. So maybe you want to try the tools refered by the other guys and at the end make your own decision.
|
|
|
|
|
Hello;
I want to want to write queue library on ANSI C. But i'm getting Damage: after normal block #42 at 0x00341000 error when executed free(ptr_queue[0]) statement. The statement frees first m_queue mallocation when i use free(ptr_queue[0]) statement?. Am i right? If not, why?
Code at below;
struct queue {
int id;
char* buffer_area;
};
int i = 0;
struct queue *m_queue;
struct queue *ptr_queue[100];
m_queue = (struct queue*)malloc(sizeof(m_queue));
m_queue->id = 1;
m_queue->buffer_area = "job-1";
ptr_queue[i] = m_queue;
i++;
m_queue = (struct queue*)malloc(sizeof(m_queue));
m_queue->id = 2;
m_queue->buffer_area = "job-2";
ptr_queue[i] = m_queue;
i++;
free(ptr_queue[0]);
ptr_queue[0] = NULL;
Thank you...
|
|
|
|
|
You are correct, but that isn't the problem.
The problem is that you are trashing memory after the allocated data. If you look at your example source, you will see you are allocating sizeof (m_queue) bytes. This is in error since the sizeof (m_queue) is just the size of a pointer, not the actual structure. Either change it to sizeof (*m_queue) or sizeof (struct queue).
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Yes. You are right. I can't believe myself!!! I'm stupid!!!
Thank you...
|
|
|
|
|
hello all
i am facing some problem when dealing with registry in HKLM(Local Machine).
it's working fine in case for debug execute, where as when i try to run same snippet in release it's not able to read.
it works fine if we just put
char Buff[xx];
wsprintf(Buff,"%s",data from regkae value);
looking for early comments
Anshuman
anshuman
|
|
|
|
|
It sounds like you are overrunning a buffer on the stack. You can always enable debug information in your release build and debug it. Of course, the optimizations will make things a little strange, but it might help.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
crazy Yaar.
check Query for registry. by jon d. 27 june
Anshu
|
|
|
|
|
I have a dialog box that I pop up as a progress indicator. There are two program modes, manual and automatic. In the manual mode, the user clicks ok when the progress is complete, which closes the progress dialog window. In automatic, when the progress is done, I need it to automatically close the dialog. The problem is, if I call DestroyWindow, without the user having clicked somewhere, I get a "User breakpoint called from [address]". Anybody had this problem before...seems kind of weird.
- John
|
|
|
|
|
Use EndDialog() function.
Cheers!!!
Carlos Antollini.
|
|
|
|
|
To programatically close the dialog, fake an OK (or Cancel) button-click by doing:
PostMessage (WM_COMMAND, IDOK);
Post Message (WM_COMMAND, IDCANCEL);
This should cause your dialog to close as if the user clicked OK.
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I have a CListCtrl with scrolling, but I was under the impression that the horizontal scrolling would only show up when needed.
However, in my case the scroll shows up everytime, even when the text is quite small.
Am i doing something particularly wrong? And what forces the horizontal scroll to show up anyways?
|
|
|
|
|
See the properies of that resource, you have the hScollBar propierty enable. In this case always you will see the Hrozontal Scrollbar visible, when the text is small it will be disabled, but when the text is large, it will be enable.
I hope to help you.
Carlos Antollini.
Is friday at night in Argentina I need =>
|
|
|
|
|
And what forces the horizontal scroll to show up anyways?
You didn't say which mode your list is in. If it's report view, then the horizontal scrollbar appears when the sum of all column widths is larger than the width of the control.
--Mike--
http://home.inreach.com/mdunn/
Ford: How would you react if I said that I'm not from Guildford after all, but from a small planet somewhere in the vicinity of Betelguese?
Arthur: I don't know. Why, do you think it's the sort of thing you're likely to say?
|
|
|
|
|
Hi everyone! Im having a little problem with this code.
I have B1 and B2 class offpring of some B class and an A class that have linked lists to B1 and B2 references to the objects it "owns".
class B {};
class B1 : public B {};
class B2 : public B {};
typedef struct B1node
{ B1 *B1obj;
B1node *next; } B1node;
typedef struct B2node
{ B2 *B2obj;
B2node *next; } B2node;
class A {
B1node *list1;
B2node *list2;
A &operator=(A& parent) {
B1node *p=parent.list1;
B2node *q=parent.list2;
B1 *obj1;
B2 *obj2;
// we are just creating new B1,B2 objects for the new
// A object and addin them to A
while(p) {
obj1=new(B1);
add_b1(*obj1);
p=p->next;
};
while(q) {
obj2=new(B2);
add_b2(*obj2);
q=q->next;
};
};
void add_b1(B1& obj1) {
B1node *p=new(B1node);
p->B1obj=&obj1;
p->next=list1; // HERE IT'S THE BUGGY SH*T !
list1=p;
};
void add_b2(B2& obj2) {
B2node *q=new(B2node);
q->B2obj=&obj2;
q->next=list2;
list2=q;
};
};
When i call the add methods regularly from main() it does just fine, but when they are called from the =OP they give some "General Protection Fault" at runtime just like they were some misused pointer. The fact is im startin to believe this could be some freaky pointer bug in MSVC++ 6.0, althought i do know that most probably its my fault.
I havent yet downloaded any SPx so i wonder if it could be a bug or its something im doing wrong (do you see some obvious flaw?)
The error jumps out (on add_b1()) when trying to assign list1 as the next node of p! that's pretty unusual!
ANY help or suggestion would be hugely apreciated
my mood stages through this issue:
then then then then
THX!
________________________________________________
Those that have really found the meaning, dont find it meaningful
|
|
|
|
|
What is the value of p?
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|