How to enforce a primay key constraint like behavior for elements of an STL container
<p>Only one element in the container can have the key property similar to how rdbms will not allow you to declare
more than one primary key on a table.
Example follows using a vector ( please consider using any other container ( <code>std</code> or <code>boost</code> ) that can accomplish the task
elegantly.</p>

<pre><code>struct Element
{
  std::wstring val_;
  bool key_;
};
std::vector&lt;Element&gt; v;
Element e1;
e1.val_ = L"Jupiter";
e1.key_ = false;
v.push_back(e1);

Element e2;
e2.val_ = L"Mars";
e2.key_ = true;
v.push_back(e2);

Element e3;
e3.val_ = L"Venus";
e3.key_ = false;
v.push_back(e3);

Element e4;
e4.val_ = L"Venus";
e4.key_ = false;
v.push_back(e4);
</code></pre>

<p>Key requirement is that if for example an attempt is made to make <code>e3.key_ = true</code> an exception should be thrown because
e2 ("Mars") already plays that role</p>

<p>Note that duplicates are allowed in this container.</p>
