#873 templates and function typedef generates uncompileable code

closed-fixed
5
2007-12-16
2007-11-15
No

%module example

%include <std_string.i>

%inline %{

#include <string>

template<typename T> class Ptr {};

class MCContract {};
typedef Ptr<MCContract> MCContractPtr;
%}

%template() Ptr<MCContract>;

%inline %{
template <class Contract, typename ContractID, typename CallbackType>
class ContractFactory
{
public:
static ContractFactory<Contract,ContractID,CallbackType> &getInstance() {
static ContractFactory<Contract, ContractID, CallbackType> instance;
return instance;
}
};
/**
* CreateXXContractCallback is a pointer to a function taking no arguments and
* returning a pointer to an XXContract.
*/
typedef MCContractPtr (*CreateMCContractCallback)();
%}

//Get around it by changing this:
%template(MCContractFactory) ContractFactory<MCContract, std::string, CreateMCContractCallback>;

//to a form which expands the typedef:
// %template(MCContractFactory) ContractFactory<MCContract, std::string, Ptr<MCContract>(*)()>;

/*
This gets generated:
ContractFactory<MCContract,std::string,Ptr< > (*)() > *result = 0 ;
It should be:
ContractFactory<MCContract,std::string,Ptr<MCContract > (*)() > *result = 0 ;
*/

Discussion

  • William Fulton

    William Fulton - 2007-12-16

    Logged In: YES
    user_id=242951
    Originator: YES

    Fixed for 1.3.34

     
  • William Fulton

    William Fulton - 2007-12-16
    • assigned_to: beazley --> wsfulton
    • status: open --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks