title: To what extent can be this a bad practice? [circular dependence]
body: <p>(First and foremost, sorry for my English)</p>
  
  <p>In order to avoid the syntactic limitation of circular dependence, I want to know if the following proposed solution is really a solution or if it has more disadventages than adventages (let's me suposse that this mutual dependence is inavoidable):</p>
  
  <p>Original situation:</p>
  
  <pre><code>class B;
  
  class A
  {
     B needed;
  };
  
  class B {};
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>B has an incomplete type.
  </code></pre>
  
  <p>"Solution":</p>
  
  <pre><code>template&lt;typename T = class B&gt;
  class tricky_A
  {
      static_assert(is_same&lt;T, B&gt;::value, "Too tricky!!");
  
      T needed;
  };
  
  class B {};
  
  using A = tricky_A&lt;&gt;;
  
  int main()
  {
     A a;  // At the instantiation point, B isn't an incomplete type.
  }
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>No problems.
  </code></pre>
  
  <p>The common solution is to make use of pointers, but I see two problems when you really don't need them:</p>
  
  <p>1) If you decide to retain pointer to other local objects, you should be sure (or the user of your class should be sure) that the life of your object is shorter than the life of the "retained" object.</p>
  
  <p>2) If you decide to deal with dynamic memory, you should spend time reserving and destructing memory, and moreover it forces you to deal with exception handling, in order to make your code exception safe.</p>
  
  <p>*) Longer code; smaller readability; harder mantenance; etc.</p>
  
  <p>Should I use this "solution" or better to search other one?</p>
  
  <p><strong>EDIT</strong>: You are all right. This isn't a real circular dependence, so, there isn't anything to ask. This question can be closed.</p>
  
  <p><strong>EDIT2</strong>: A better question <a href="https://stackoverflow.com/questions/15953918/to-what-extent-can-be-this-a-bad-practice-circular-dependence">here</a>.</p>