Function templates in C++

By , last updated February 16, 2010

A reference to myself.

Function templates have two faces. Either they are a member of a non-template class, or they are free functions in the global or some namespace.

These are a member of a non-template class, with function templates.

// filename: interface.hpp
class interface
	template<typename RESULTS, typename DATA>
	void insert(RESULTS &results, const DATA &data);
// filename: interface.cpp

#include "interface.hpp"

// Full specialization
void interface::insert<>( Results &results, const Data &data )
	// do stuff

Professional Software Developer, doing mostly C++. Connect with Kent on Twitter.


Be the first to comment.

Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>