Template visibility
Ethan Watson via Digitalmars-d
digitalmars-d at puremagic.com
Wed Aug 31 05:45:14 PDT 2016
https://github.com/Remedy-Entertainment/binderoo/blob/master/binderoo_client/d/src/binderoo/typedescriptor.d
Inside that is some code I have to translate D types to the C++
strings that we expect.
I'm in the middle of making a mathematical vector class that I
will be sticking in Binderoo, but maps functionality to our
internal SIMD vector class. As such, to keep Binderoo a clean
interface for anyone to use, it will not contain any @CTypeName
UDAS for Remedy-specific type info.
The problem comes when I try to alias to the expected type for
our D code and provide a C++ string override, like so:
//----------------------------------------------------------------------------
module remedy.rl.simdvector;
public import binderoo.math.vector;
public import binderoo.typedescriptor;
alias SIMDVector = binderoo.math.vector.VectorFloat;
enum CTypeNameOverride( T : SIMDVector ) = "r::SIMDVector";
pragma( msg, CTypeString!( SIMDVector ) );
//----------------------------------------------------------------------------
The CTypeString template has no visibility to my
CTypeNameOverride, and as such that pragma prints out
"VectorFloat" instead of "r::SIMDVector".
Is there some way to mitigate this without needing to resort to
mixins everywhere? This is one of those things in C++ where if I
specialise a template, any invocation of the template after that
point will go to the specialised version. But in this case,
because instantiation happens within the scope of the
binderoo.typedescriptor module instead of within the scope of the
module the template is invoking from, it just can't see my new
CTypeNameOverride specialisation.
I do have other instances inside the Binderoo code where I
resolve the module names for symbols and mixin an import for that
to make it all just work, but I'm getting tired of having to do
that every time I come across this problem.
More information about the Digitalmars-d
mailing list