Interoperability, code & marketing

Nicholas Wilson iamthewilsonator at hotmail.com
Tue Jul 3 14:40:52 UTC 2018


If [1] gets merged we will have a situation where code[2] is 
required to interoperate with D's slices from C++. I think we 
should have an official repository where such code and 
documentation lives (i.e. on the dlang github). This would also 
be a good place to have links to other interoperability successes 
in D like pyd, dpp, embedr, luad,  autowrap etc. and put the D 
interoperability story out there, coherently and in one place.

Thoughts?

[1]: https://github.com/dlang/dmd/pull/8120
[2]:
template<typename T>
struct __dslice
{
     size_t length;
     T* ptr;

     __dlisce(size_t len, T* p)
     {
         length = len;
         ptr    = p;
     }
     /**
      * Container constructor:
      *
      * Accepts any type U that satisfies `U u; size_t i = 
u.size(); T* = u.data();`
      * This includes types like:
      *      std::vector,
      *      std::string,
      *      std::string_view
      *      std::span
      *
      * TODO: Constrain this properly such that U::value_type == T 
(modulo const)
      * TODO: Make this const correct
      */
     template<typename U>
     __dslice(U& u)
     {
         length = u.size();
         ptr    = const_cast<T*>(u.data());
     }
};


More information about the Digitalmars-d mailing list