Files
clang-uml/docs/test_cases/t20009.md
2022-11-30 21:32:37 +01:00

1.0 KiB

t20009 - Smart pointer dereference call expression test case

Config

compilation_database_dir: ..
output_directory: puml
diagrams:
  t20009_sequence:
    type: sequence
    glob:
      - ../../tests/t20009/t20009.cc
    include:
      namespaces:
        - clanguml::t20009
    using_namespace:
      - clanguml::t20009
    start_from:
      - function: "clanguml::t20009::tmain()"

Source code

File t20009.cc

#include <memory>
#include <string>

namespace clanguml {
namespace t20009 {
template <typename T> struct A {
    void a(T arg) { }
};

template <typename T> struct B {
    void b(T arg) { a->a(arg); }

    std::unique_ptr<A<T>> a;
};

using BFloatPtr = std::shared_ptr<B<float>>;

void tmain()
{
    std::shared_ptr<B<std::string>> bstring;
    auto bint = std::make_unique<B<int>>();
    BFloatPtr bfloat;

    bstring->b("b");
    bint.get()->b(42);
    bfloat->b(1.0);
}
}
}

Generated UML diagrams

t20009_sequence