title: Does C++/CX detect and solve cycles of objects?
body: <p>From my <a href="https://stackoverflow.com/questions/7424710/does-winrt-have-garbage-collection">understanding</a> C++/CX doesn't use garbage collection, it use a reference counted approach instead.</p>
  
  <p>The problem with reference counting is that it cannot dispose of cycles. Cycles are usually solved using weak references, such as weak_ptr in standard C++.</p>
  
  <p>But I cannot find a way in C++/CX to explicitly specify a weak reference. From that I would assume that this is handled by C++/CX itself. I am wondering how C++/CX would solve this.</p>
  
  <p>For instance, look at the following code:</p>
  
  <pre><code>ref class Foo
  {
  public:
      Bar^ bar;
  };
  
  ref class Bar
  {
  public:
      Foo^ foo;
  };
  
  ref class App
  {
  public:
      virtual void OnLaunched(LaunchActivatedEventArgs^ args)
      {
          Foo^ foo = ref new Foo();
          Bar^ bar = ref new Bar();
          foo.bar = bar;
          bar.foo = foo;
      }
  };
  </code></pre>
  
  <p>How does C++/CX detect this cycle?</p>
  
  <p>How does C++/CX solve this cycle?</p>
  
  <p>How does C++/CX decide which one of these objects should be the "root object" and which one should be the "weak reference"?</p>