New templated method SwigValueInit to initialise all types - used initially for return types in director methods

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10063 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2007-10-28 23:07:33 +00:00
commit 421eb7ae60
3 changed files with 18 additions and 4 deletions

View file

@ -632,7 +632,7 @@ namespace std {
#ifdef __cplusplus
%insert("runtime") %{
#ifdef __cplusplus
template<class T> class SwigValueWrapper {
template<typename T> class SwigValueWrapper {
T *tt;
public:
SwigValueWrapper() : tt(0) { }
@ -644,7 +644,21 @@ public:
T *operator&() { return tt; }
private:
SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
};
};%}
/*
* SwigValueInit() is a generic initialisation solution as the following approach:
*
* T c_result = T();
*
* doesn't compile for all types for example:
*
* unsigned int c_result = unsigned int();
*/
%insert("runtime") %{
template <typename T> T SwigValueInit() {
return T();
}
#endif
%}
#endif