WIP Solution draft for defining an output mapping type

This commit is contained in:
Fischlurch 2010-11-25 04:52:49 +01:00
parent a7ec680955
commit 645ddd284c
3 changed files with 19 additions and 15 deletions

View file

@ -41,7 +41,7 @@
**
** Most of these trait templates rely on a creative use of function overloading. The C++ standard
** requires the compiler <i>silently to drop</i> any candidate of overload resolution which has
** gotten an invalid function signature as a result of instantiating a template (type). This allow
** gotten an invalid function signature as a result of instantiating a template (type). This allows
** us to set up kind of a "trap" for the compiler: we present two overloaded candidate functions
** with a different return type; by investigating the resulting return type we're able to figure
** out the overload actually picked by the compiler.

View file

@ -245,11 +245,12 @@ namespace asset {
template ID<Asset> AssetManager::reg (Asset* obj, const Asset::Ident& idi);
template P<Asset> AssetManager::getAsset (const ID<Asset>& id) throw(lumiera::error::Invalid);
template P<Media> AssetManager::getAsset (const ID<Media>& id) throw(lumiera::error::Invalid);
template P<Proc> AssetManager::getAsset (const ID<Proc>& id) throw(lumiera::error::Invalid);
template P<Struct> AssetManager::getAsset (const ID<Struct>& id) throw(lumiera::error::Invalid);
template P<Meta> AssetManager::getAsset (const ID<Meta>& id) throw(lumiera::error::Invalid);
template P<Asset> AssetManager::getAsset (const ID<Asset>& id);
template P<Media> AssetManager::getAsset (const ID<Media>& id);
template P<Proc> AssetManager::getAsset (const ID<Proc>& id);
template P<Struct> AssetManager::getAsset (const ID<Struct>& id);
template P<Meta> AssetManager::getAsset (const ID<Meta>& id);
template P<Pipe> AssetManager::getAsset (const ID<Pipe>& id);
template P<Asset> AssetManager::wrap (const Asset& asset);
template P<Media> AssetManager::wrap (const Media& asset);

View file

@ -33,13 +33,12 @@ namespace mobject {
namespace { // Helper to extract and rebind definition types
using std::tr1::function;
template<class DEF>
struct _def
class _def
{
typedef asset::ID<asset::Pipe> PId;
template<typename RET>
RET extractFunctionSignature (RET(DEF::*func)(PId));
typedef asset::ID<asset::Pipe> PId;
template<typename FUN>
struct Rebind;
@ -50,11 +49,12 @@ namespace mobject {
typedef RET Res;
};
typedef typeof(&DEF::output) OutputMappingMemberFunc; // GCC extension: "typeof"
typedef Rebind<OutputMappingMemberFunc> Rebinder;
typedef typename Rebind<&DEF::output> Rebinder;
typedef typename Rebinder::Res Res;
typedef typename function<Res(PId)> OutputMappingFunc;
public:
typedef typename Rebinder::Res Target;
typedef function<Target(PId)> OutputMappingFunc;
};
}
@ -73,7 +73,10 @@ namespace mobject {
template<class DEF>
class OutputMapping
{
typedef _def<DEF> Setup;
public:
typedef typename Setup::Target Target;
};