Template Specialization In many cases when working with templates, you'll write one generic version for all possible data types and leave it at that--every vector may be implemented in exactly the same way. The idea of template specialization is to override the default template implementation to handle a particular type in a different way. For instance, while most vectors might be implemented as arrays of the given type, you might decide to save some memory and implement vectors of bools as a vector of integers with each bit corresponding to one entry in the vector. So you might have two separate vector classes. The first class would look like this. template <typename T> class vector { // accessor functions and so forth private: T* vec_data; // we'll store the data as block of dynamically allocated // memory int length; // number of elements used int vec_size; // actual size of vec_data }; But when it comes t...
"Jesus, you're serious about this, aren't you?" Dupre nervously crushed out his cigarette, staring at me glassy-eyed. "Never been more." He extracted another Gauloise. "Okay, a counteroffer, Miss . . ." "James. Morgan James." "Right, Miss James. I'm beginning to think you've got no realistic sense of proportion about this part of the world. You—" "Fools rush in, right?" "My point precisely. But if Steve here means what he says, well, maybe there's a little room to negotiate. Maybe I could take you on a quick sightseeing trip. And just for laughs I could kind of inadvertently stray over the area I think you might find productive. Assuming we can locate it. But here're my terms. I do it and Steverino and me are square. Consider it a twenty-thousand- dollar cruise." "Fine with me." Steve didn't even blink, and I loved him all over again...
Comments
Post a Comment