non-local function call local type
<pre><code>   432     void RoleExternModel::getShareConfig(SourceList&amp; sourceList, std::vector&lt;UInt16&gt;&amp; packs, ShopModel&amp; shopModel)
   433     {
   434         std::copy(Packs, Packs + SHARE_PRIZE, std::insert_iterator&lt;std::vector&lt;UInt16&gt; &gt;(packs, packs.begin()));
   435         struct Fun {
   436             std::vector&lt;std::pair&lt;UInt16, UInt8&gt; &gt; pairs;
   437             void operator () (UInt16 type) {
   438                 pairs.push_back(std::make_pair&lt;UInt16, UInt8&gt;(type, Configuration::PACKS));
   439             }
   440         };
   441         Fun fun();
   442         std::for_each(Packs, Packs + SHARE_PRIZE, fun);
   443         shopModel shopModel(fun.pairs);
   444         shopModel.load(sourceList);
   445     }
</code></pre>

<p>why the  compiler said : </p>

<blockquote>
  <p>error: non-local function
  ‘Pet::RoleExternModel::getShareConfig(Pet::SourceList&amp;,
  std::vector >&amp;,
  Pet::ShopModel&amp;)::Fun Pet::fun()’ uses local type
  ‘Pet::RoleExternModel::getShareConfig(Pet::SourceList&amp;,
  std::vector >&amp;,
  Pet::ShopModel&amp;)::Fun’</p>
</blockquote>

<p>how to make it legel?</p>
