templates

C++ increment operator

How to differentiate between overloading the 2 versions of operator ++ ? const T& operator ++(const T& rhs) which one? i++; ++i; ...

Merging two templates in iText

Let's say I have two PDF templates created with Adobe Acrobat, which are both single-page, 8.5x11 documents. The first template (A.pdf) has content for the top half of the page. The second template (B.pdf) has content for the bottom half of the page. (It just so happens the content in both templates does not "overlap" each other.) I wou...

Template Child Class Overriding a Parent Class's Virtual Function

The below code compiles with gcc v4.3.3 and the templated child class seems to be overriding a virtual function in the parent, but doesn't that break the rule that you cannot have a virtual template function? Or is something else happening that I don't understand? class BaseClass { public: virtual void Func(int var) { std::cout...

what are the facilities for frames and templates in dreamweaver?

what are the facilities for frames and templates in dreamweaver? is it creating frames, creating nested frames and so on.. ...

template; Point<2, double>; Point<3, double>

Hi, I want to create my own Point struct it is only for purposes of learning C++. I have the following code: template <int dims, typename T> struct Point { T X[dims]; Point(){} Point( T X0, T X1 ) { X[0] = X0; X[1] = X1; } Point( T X0, T X1, T X2 ) { X[0] = X0; X[1] = X1; X[2...

overloading new/delete problem

This is my scenario, Im trying to overload new and delete globally. I have written my allocator class in a file called allocator.h. And what I am trying to achieve is that if a file is including this header file, my version of new and delete should be used. So in a header file "allocator.h" i have declared the two functions extern voi...

allocator with no template

Every stl container take an allocator as a parameter: template < class T, class Allocator = allocator<T> > class vector; If you write your own class It is possible to use your own allocator. But is it possible to write your own allocator without using templates? For example, writing this function is not easy if you are not allowed to...

Theme the node-create and node-edit template

I'm using drupal 6. I've managed to make a .tpl file for one content type, that is for images in my image gallery. I did that by adding this code in template.php: function artbasic_theme($existing, $type, $theme, $path) { return array( 'galleryimage_node_form' => array( 'arguments' => array('form' => NULL), 'templa...

Template Sort In C++

Hey all, I'm trying to write a sort function but am having trouble figuring out how to initialize a value, and making this function work as a generic template. The sort works by: Find a pair =(ii,jj)= with a minimum value = ii+jj = such at A[ii]>A[jj] If such a pair exists, then swap A[ii] and A[jj] else b...

Design pattern question: encapsulation or inheritance

Hey all, I have a question I have been toiling over for quite a while. I am building a templating engine with two main classes Template.php and Tag.php, with a bunch of extension classes like Img.php and String.php. The program works like this: A Template object creates a Tag objects. Each tag object determines which extension class (...

C++ invoke explicit template constructor

hello. Can you tell me how to invoke template constructor explicitly (in initializer list)? for example: struct T { template<class> T(); }; struct U { U() : t<void>() {} //does not work T t; }; thanks ...

How to save MS Word template file (dotx) as docx when document is opened in Internet Explorer

I am maintaining a web application that allows word template documents do be opened inside the browser. Recently the client upgraded to windows 7 and MS Word 2007 and my problems started... When a template document is opened inside the browser and saved, the original file is overwrited instead of a new word file being created. Is ther...

std::make_shared as a default argument does not compile

In Visual C++ (2008 and 2010), the following code does not compile with the following error: #include <memory> void Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) ) { } class P { void Foo( std::shared_ptr< int > test = ::std::make_shared< int >( 5 ) ) { } }; error C2039: 'make_shared' : is not a...

algorithms that destruct and copy_construct

I am currently building my own toy vector for fun, and I was wondering if there is something like the following in the current or next standard or in Boost? template<class T> void destruct(T* begin, T* end) { while (begin != end) { begin -> ~T(); ++begin; } } template<class T> T* copy_construct(T* begin, T* ...

Designing template for Ruby on Rails view. What and where to learn?

Hi. I have a project going on, and I am in charge of the front-end design, whereas my developers will work on the back-end with Ruby on Rails. I do not know Ruby on Rails, and am designing front-end using XHTML, CSS, jQuery, 960.gs CSS Framework. My developer is supposed to take my design and connect the elements of back-end to it, with...

Practise Questions for Templates,Functors,CallBack functions in c++?

Hi, I have been reading templates,functors,callback function for the past week and have referred some good books and articles. I however feel that, unless I can get good practice - programming in templates and use functors-callbacks there is no way I can really understand all the concepts or fluently use them while coding. Could any...

Initilizing a static class member that depends on a private template type (C++)

Hi, I have the following situation: class Test { private: class SubType { //... }; static std::vector<SubType> v; }; Because v is static, I initilize it in the cpp file with std::vector<Test::SubType> Test::v; But this does not work, the compiler tells me that "Test::SubType" is private. What can I do about thi...

What was Tim Sweeney thinking? (How does this C++ parser work?)

Tim Sweeney of Epic MegaGames is the lead developer for Unreal and a programming language geek. Many years ago posted the following screen shot to VoodooExtreme: As a C++ programmer and Sweeney fan, I was captivated by this. It shows generic C++ code that implements some kind of scripting language where that language itself seems to b...

template class: ctor against function -> new C++ standard

Hi in this question: http://stackoverflow.com/questions/2779155/template-point2-double-point3-double Dennis and Michael noticed the unreasonable foolishly implemented constructor. They were right, I didn't consider this at that moment. But I found out that a constructor does not help very much for a template class like this one, instead ...

C++ Namespaces & templates question

Hi! I have some functions that can be grouped together, but don't belong to some object / entity and therefore can't be treated as methods. So, basically in this situation I would create a new namespace and put the definitions in a header file, the implementation in cpp file. Also (if needed) I would create an anonymous namespace in t...