1
0

xhierarchy_generator.hpp 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /***************************************************************************
  2. * Copyright (c) Johan Mabille, Sylvain Corlay and Wolf Vollprecht *
  3. * Copyright (c) QuantStack *
  4. * *
  5. * Distributed under the terms of the BSD 3-Clause License. *
  6. * *
  7. * The full license is in the file LICENSE, distributed with this software. *
  8. ****************************************************************************/
  9. #ifndef XTL_HIERARCHY_GENERATOR_HPP
  10. #define XTL_HIERARCHY_GENERATOR_HPP
  11. #include "xmeta_utils.hpp"
  12. namespace xtl
  13. {
  14. /*********************************
  15. * scattered hierarchy generator *
  16. *********************************/
  17. template <class TL, template <class> class U>
  18. class xscatter_hierarchy_generator;
  19. template <template <class> class U, class T, class... Args>
  20. class xscatter_hierarchy_generator<mpl::vector<T, Args...>, U>
  21. : public U<T>, public xscatter_hierarchy_generator<mpl::vector<Args...>, U>
  22. {
  23. };
  24. template <template <class> class U>
  25. class xscatter_hierarchy_generator<mpl::vector<>, U>
  26. {
  27. };
  28. /******************************
  29. * linear hierarchy generator *
  30. ******************************/
  31. class default_root {};
  32. template <class TL, template <class, class> class U, class Root = default_root>
  33. class xlinear_hierarchy_generator;
  34. template <template <class, class> class U, class Root, class T0, class... Args>
  35. class xlinear_hierarchy_generator<mpl::vector<T0, Args...>, U, Root>
  36. : public U<T0, xlinear_hierarchy_generator<mpl::vector<Args...>, U, Root>>
  37. {
  38. public:
  39. using base_type = U<T0, xlinear_hierarchy_generator<mpl::vector<Args...>, U, Root>>;
  40. template <class... T>
  41. inline xlinear_hierarchy_generator(T&&... args)
  42. : base_type(std::forward<T>(args)...)
  43. {
  44. }
  45. };
  46. template <template <class, class> class U, class Root>
  47. class xlinear_hierarchy_generator<mpl::vector<>, U, Root>
  48. : public Root
  49. {
  50. public:
  51. template <class... T>
  52. inline xlinear_hierarchy_generator(T&&... args)
  53. : Root(std::forward<T>(args)...)
  54. {
  55. }
  56. };
  57. }
  58. #endif