|
What's your os now and what was it previous?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
|
ganesh.dp wrote: help me to solve this one...
It could be any number of reasons. Start here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi all. Slightly tricky one here.
I have a template class that has more than one template argument, for example:
<br />
template< class X, int N ><br />
class Foo<br />
{<br />
public: <br />
int GetValue() const;<br />
};<br />
Now, say that I want to specialize GetValue so that it returns, say, 69 for a template argument of N = 5, but returns 42 for all other values of N. For example:
<br />
Foo< char, 3 > foo1;<br />
foo1.GetValue();
<br />
Foo< double, 17 > foo2;<br />
foo2.GetValue();
<br />
Foo< bool, 5 > foo3;<br />
foo3.GetValue();
One way that would work is to specialize the entire class for N = 5 and again for all other values, so as to provide two separate implementations of the class. For example:
<br />
template< class X, int N ><br />
class Foo<br />
{<br />
public:<br />
int GetNumber() const { return 42; }<br />
};<br />
<br />
template< class X ><br />
class Foo< X, 5 ><br />
{<br />
public:<br />
int GetNumber() const { return 69; }<br />
};<br />
But I want to avoid this approach because while it works well for this simple example class with only one function, I am in practice trying to specialize a member function on a much larger class with many functions that would be unchanged by the specialization. Thus, I need a method to specialize only the member function in question, without duplicating the rest of class Foo.
As far as I can determine, specializing the member function only works if it has a single template parameter, like so:
<br />
template< int N ><br />
class Foo<br />
{<br />
public:<br />
int GetNumber() const { return 42; }<br />
};<br />
<br />
template < int N ><br />
int Foo< N >::GetNumber() const { return 42; }<br />
<br />
template < ><br />
int Foo< 5 >::GetNumber() const { return 69; }<br />
Can anyone explain how I can apply this logic to the case of multiple template arguments? The following code, by way of example, does not compile.
<br />
template< class X, int N ><br />
class Foo<br />
{<br />
public:<br />
int GetNumber() const { return 42; }<br />
};<br />
<br />
template < class X, int N ><br />
int Foo< X, N >::GetNumber() const { return 42; }<br />
<br />
template < class X ><br />
int Foo< X, 5 >::GetNumber() const { return 69; }<br />
Any help would be greatly appreciated.
|
|
|
|
|
Why don't you simply make a check inside the function.
template< class X, int N>
class Foo
{
public:
int GetValue() const
{
return 5 == N ? 69 : 42;
}
};
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Jmuulian wrote: As far as I can determine, specializing the member function only works if it has a single template parameter, like so:
No, it's because it is fully specialised. The compiler will implicitly instantiate the class for that template parameter and specialise the method (see 14.7.3p4 of the 1998 C++ standard).
Jmuulian wrote: Can anyone explain how I can apply this logic to the case of multiple template arguments? The following code, by way of example, does not compile.
template< class X, int N >
class Foo
{
public:
int GetNumber() const { return 42; }
};
template < class X, int N >
int Foo< X, N >::GetNumber() const { return 42; }
template < class X >
int Foo< X, 5 >::GetNumber() const { return 69; }
These are attempted partial specialisations. Trouble is, the template parameters are on the class, not the method, so you have to partially specialise the class, not just the method. To do what you want, the compiler would have to implicitly partially instantiate the class template - it won't do that.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi,
I have a requirement to open a .net application from within a C++ application. Can anyone of you please help me in this regard.
Thanks in advance.
Siva.
|
|
|
|
|
What do you mean by open an application?
If you want to execute a .NET executable, you can do so using CreateProcess .
If it is a DLL that you want to load, you will have to create a COM Callable Wrapper (CCW) for your .NET application and then use it within C++ just like it is a COM component.
Please refer to the documentation on CCW.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
if you have the binary you can use ShellExecute and for finer control use CreateProcess.
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Hi everybody
In my application i want to receive some data and after reeving the data i have to perform some operation.
For the data to come it will take some 0 to 3 sec.
So i am using Sleep(3000) to wait the data to come.But some times the data will come in less than 1 second.So unnecessary i have to wait.
Before i was using this algorithm
While(dataHasNotCome)
{
//wait
}
But it failed as the data may not come sometimes and be in infinite loop.
I can use a counter and increment it till a particular value and stop the loop.
Other than that is there any other method.
Regards
Deepu
|
|
|
|
|
You can use asynchronous read here.
Since you have not mentioned how you are reading data, I will assume you can use the file manipulation functions on some sort of handle or you are using sockets.
If you are accessing a handle can use ReadFile or ReadFileEx with an OVERLAPPED structure.
For sockets you can use WSARecv function with an OVERLAPPED structure.
After calling the function you can wait on the event handle inside the OVERLAPPED structure.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
I am reading data from the COM port.It is happening in a thread and it keep on reading the data and this data is stored in one CMainFrame variable.
My part is to get this variable in my class and do some manipulations after the data has come.
The only thing i have to do is to check the data has come or not.
|
|
|
|
|
Open the port with the overlapped flag.
CreateFile(_T("COM1"), GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0);
Post the asynchronous read.
OVERLAPPED over = { 0 };
over.hEvent = ::CreateEvent(0, 0, 0, 0);
DWORD dwRead = 0;
ReadFile(m_hPort, buffer, len, &dwRead, &over);
Wait on the event for 3 seconds.
if (WAIT_OBJECT_0 != WaitForSingleObject(over.hEvent, 3000))
return;
GetOverlappedResult(m_hPort, &over, &dwReade, 0);
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
|
Why don't you register a callback in the module where data is rcvd. and call that callback as soon as (dataHasCome)
|
|
|
|
|
Reading on a COM-Port is fine be reading 1 (in words: "one") byte while waiting for completion (or time out)
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Where does the data come from? For most input devices, there is some way of blocking until the input device has some data, rather than having to sleep.
But we can't help you if you don't give us that detail!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Assuming your data is coming via the serial port, read here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
|
Is that a IWebBrowser2 wrapper class ? Check this site[^] for more information.
Also, please look at the Navigate[^] method.
|
|
|
|
|
Hi,
I am trying to size my Rich edit Dialog box to fit a certain amount of characters on a line of Multiedit Rich Edit control
It would be helpfull to know logfont Height and long font width
I have tried in My Initdialog rtn to get this info
by dointg CFOnt * CRichEdit::GetFont however it seems the the Font has'nt been set as yet
GetDegaultCharFormat doesn't return any size info I know the CharFormat structure doesn't have a Width members
but the hieght is zero
Maybe becuase I haven't sized My Edit Control via MoveWindow
would anyone know when (maybe somne message e.g. WM_SETFONT) that rich edit populates the Height/Width of the font
thankx
|
|
|
|
|
The documentation[^] says:
The return value is a handle to the font used by the control, or NULL if the control is using the system font
I suspect the system font is being used, in which case GetStockObject(SYSTEM_FONT) should return the required font handle?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I just wonder Height and width fields have something else besides zeros
As I would like to use the width to size up number characters I can have on a line
I'll try it out
thankx
|
|
|
|
|
This code in my OnInitDialog:
CFont* f = richEd.GetFont();
if (!f) f = CFont::FromHandle((HFONT)GetStockObject(SYSTEM_FONT));
LOGFONT lf;
f->GetLogFont(&lf);
yields
lf.lfHeight = 16
lf.lfWidth = 7
when the rich-edit is (presumably) using the stock font.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
thznkx so so so so so much ............
The Rich Edit control in my resource file is sizes are all zeros (0,0,0,0) as I plan to size
it myself Hope it wont effect hiegt and width
I'll give it a shot
thankx again
|
|
|
|