|
Stuart Dootson wrote: You might also want to investigate std::deque - this allocates storage as a linked list of blocks, meaning that new allocations don't require relocation of existing elements.
A deque is not a linked list. It is a specialized array that allows for quick insertion at both the front and back of the array. All the memory for a deque is contiguous, just as it is for a vector.
Stuart Dootson wrote: As for GrowBy - you're out of luck there
Not really. If you really want to customize how memory allocation is done for a given STL container, you just need to write your own allocator and pass it in as the second template parameter. This is generally not needed since the default allocator is sufficient for almost all cases, though.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Zac Howland wrote: All the memory for a deque is contiguous
Hmmm - not in my copy of VS 2003 (or GCC 3.4.5) - see this[^] and try the program below...
#include <deque>
#include <iostream>
int main(int, char**)
{
std::deque<char> x;
x.resize(10);
if (&x.back()-&x.front() == std::distance(x.begin(), x.end())-1)
{
std::cout << "x is contiguous\n";
}
else
{
std::cout << "x is not contiguous\n";
}
x.resize(1e6);
if (&x.back()-&x.front() == std::distance(x.begin(), x.end())-1)
{
std::cout << "x is contiguous\n";
}
else
{
std::cout << "x is not contiguous\n";
}
}
outputs
x with 10 elements is contiguous
x with 1000000 elements is not contiguous
|
|
|
|
|
I should have rephrased that. All the memory for each chunk in a deque is contiguous. That is, it allocates a fixed size chunk, when it gets filled, it allocates another fixed size chunk. My point was that it isn't a linked-list; its closer to being a map.
MSDN
SGI's Implementation
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Sounds more like a linked list of arrays to me than a map.
--
Mit viel Oktan und frei von Blei, eine Kraftstoff wie Benziiiiiiin!
|
|
|
|
|
Does anyone know how to use WTL's CDoubleBufferImpl? Any article about it?
BTW: What's the meaning of "Double Buffer" within "CDoubleBufferImpl"?
|
|
|
|
|
shaohao wrote: CDoubleBufferImpl
Google finds this[^]?
|
|
|
|
|
The WM_PAINT handler sets up a memory DC and calls the derived class's DoPaint() method. That way, all your own window classes don't have to have the boilerplate double-buffering code (create a mem DC, paint to it, blit to the screen when done).
--Mike--
Visual C++ MVP
LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
All,
I am working on ATL COM DLL and I am writing a DLL which exposes few interfaces to the application. These interfces can be called either from the VBScript or C++ routine. Any rules which i need to follow especially for having a parameter[[IN], [OUT]. As every one knows that VBScript has data type limitations and we can't pass all the parameters as like in normal. For example the IN and OUT parameter will be used to send and receive values from the interfce and should always be having a VARIANT* data type.
For example:
1. STDMETHODIMP CXX::FUNC_XX( BYTE bnl,BYTE bCurrCl,VARIANT* vSData,BOOL boFlag, SHORT *pRetVal)
2. STDMETHODIMP CXXX::FUNC1_XXX(VARIANT* vReconfig,SHORT *pRetVal)
Please let me know if any one is having suggestions or sample ATL COM DLL which can be called from VBScript.
Thanks,
AKS
|
|
|
|
|
Hi
When I started C++ I used MFC. I found CString a doddle to use sadly it turned out to be not exactly the finest of string implementations.
Has this been resolved in the WTL or should I stick with the STL string or lower level self made implementations?
Thanks
Tom
|
|
|
|
|
What versions of ATL, WTL and MFC are you using? If it's the ATL+MFC that came with VS.NET, then WTL uses the ATL CString...which is the same as the MFC one...which is a *complete* rewrite compared to the previous version of MFC.
Otherwise, I think the CString that was in WTL was much the same as the precious MFC one.
Also - what issues did you have with the MFC CString? Not that I've used it that much, I'm just interested
|
|
|
|
|
TClarke wrote: When I started C++ I used MFC. I found CString a doddle to use sadly it turned out to be not exactly the finest of string implementations.
I assume you are referring to how it allocates memory, since other than that, it actually offers many features that even the STL string class doesn't give.
TClarke wrote: Has this been resolved in the WTL or should I stick with the STL string or lower level self made implementations?
The answer to this question largely depends on what you are doing. If you are trying to write portable code, I would use std::string. If you are writing Windows-only code and have need for doing certain kinds of string operations, CString is probably the way you want to go.
The newest versions of WTL/ATL/MFC all use the same implementation of CString. Older versions were slightly different for MFC than the other toolkits.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
|
Firstly, thank you to all of you for your respones
I'm using VS.NET creating code only to be used on Windows.
It's encouraging to hear that CString no longer has the reputation it did whilst in it's VC6 incarnation. The issue that alarmed me was that it was considered inefficient and slow, a heavy weight implementation included to bridge the gap until the STL string was completed. though I never noticed any cost to my programs in terms of speed or size.
"Also - what issues did you have with the MFC CString? Not that I've used it that much, I'm just interested"
My main issue is more with the STL implementaion as CString has never been any trouble to use. Why the STL string does not have an implemmentation of CString::Find, or CString::Format and all those Windows crucial overloads that makes CString a breeze to use I don't know but it's always put me off
Thanks
Tom
|
|
|
|
|
Hi
Does any know of a reason for not utilizing the WTL library when writing ActiveX controls in ATL?
Thanks
Tom
|
|
|
|
|
If you are doing windowless controls, then WTL is pretty much useless. If not, then WTL will serve you well.
--
Not based on the Novel by James Fenimore Cooper
|
|
|
|
|
Thanks
|
|
|
|
|
Hi,
I have an array A[10][2].
The first column of the array consists of marks and the second consists of student code number.
I want to sort the array based on the first column.
How do I use stl::sort() to achieve this?
Cutebug
|
|
|
|
|
You can't - arrays aren't assignable objects (i.e. you can't do x = y; where x and y are of type int[2] ), which is a requirement of any of the mutating algorithms.
I'd suggest you use records instead (oh, and std::vector s for storage rather than arrays):
#include <algorithm>
#include <vector>
struct Mark
{
int mark;
int studentCode;
};
bool operator<(Mark const& left, Mark const& right) { return left.mark < right.mark; }
int main(int, char**)
{
std::vector<Mark> marks;
std::sort(marks.begin(), marks.end());
}
Try to forget arrays ever existed...
|
|
|
|
|
Thank you!
Cutebug
|
|
|
|
|
Does anyone know how to use WTL's CToolTipCtrl in dialog box with TTN_NEEDTEXT?
I want to popup a tooltip when mouse hover each control in dialog box.
|
|
|
|
|
|
|
We try to execute a console application as a noninteractive user (NT AUTHORITY/SYSTEM).This console application is supposed to launch an IE process ,and perform certain steps.But it fails to launch the IE browser - is this a characterisitc of such user accounts?If so,is there some way I can make this account launch the browser?I am able to launch the IE broswer successfulyl when i execute as a normal domain account
|
|
|
|
|
Hello, im using wtl to create static text ctrls. The problem is that the background color of these controls does not default to the default color of a plain client window. Which is white in xp and system-grey in windows2000. The color of the static-ctrl is system-grey aswell.
It looks like crap, see it here:
http://hem.passagen.se/storage/bad-color-static-ctrls.jpg
Question: How do i set the background color of the static control, alt, the color of the window, to a default system color which they can share on any windows version.
Im looking for something like AtlGetDefaultGuiFont() but for color.
And how to set it.
Thanks in advance.
|
|
|
|
|
GetSysColor(COLOR_3DFACE) and GetSysColorBrush(COLOR_3DFACE) will give you the colour and a brush. To persuade a static to paint it's background a different colour, the parent needs to handle WM_CTLCOLORSTATIC and return the brush that it wants the static to use.
That help at all?
Steve S
Developer for hire
|
|
|
|