Skip to content

TreeInfo interface is not suitable for dynamic nodes

This is the interface of TreeInfo:

    template<typename Tree, typename Tag = StartTag>
    struct TreeInfo
    {
      //! The depth of the TypeTree.
      static const std::size_t depth = ...;

      //! The total number of nodes in the TypeTree.
      static const std::size_t nodeCount = ...;

      //! The number of leaf nodes in the TypeTree.
      static const std::size_t leafCount = ...;
    };

Using this interface is not suitable because the intended use is so that the object is never constructed: (i.e. node_count = TreeInfo<MyTree>::nodeCount) Now the question is: how do we account for the dynamic nodes?

  • In !55 (closed) I proposed to add free-standing functions for leafCount(), nodeCount(), and depth() that calculated it either from static or dynamic information. In this form, the TreeInfo would only serve as a helper class for the static case and should be deprecated for external usage.
  • Another idea could be to store this info in the nodes themselves, but that might complicate a future mutable implementation of the dynamic nodes.
  • Do you have other ideas?