C++/ D C struct2 D inner classes, C++ templates/D templates

BLS nanali at nospam-wanadoo.fr
Thu Jul 26 08:06:20 PDT 2007

Hi :
it is about translating a C++ B+Tree algoritm into D.
Question No1 <g>
#include <algorithm>
#include <functional>
etc. and so on

*The C++* source looks like :
template <typename _Key, typename _Data,
           typename _Value = std::pair<_Key, _Data>,
           typename _Compare = std::less<_Key>,
           typename _Traits = btree_default_map_traits<_Key, _Data>,
           bool _Duplicates = false>

class bptree
     typedef _Key                        key_type;

   //etc, and so on

private :
   struct node
     //contains somethink like
     inline void initialize(const unsigned short l)
       level = l;
       slotuse = 0;
   struct inner_node : public node


*IN D*, I would like to use adaptor classes instead of structs -> struct 

class BplusTtree(_Key, _Data, and so on, bool _Duplicates=false)
   class node(){}
   // and
   class inner_node : node{}


Is this legal ?

No2 :
The code contains std::pairs, (for key, value pairs)
What is the fasted (execution-speed) way to implement this in D ?

No3 :
C++ *prepare_cast, static_cast* just cast(whatever) in D ?

Sorry for beeing so ignorant but I just have basic C++ knowhow, and I am 
  still learning about D templates. Many thanks in advance

More information about the Digitalmars-d-learn mailing list