我的插入成员函数有以下声明:
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<nav id="navbar-section" class="navbar navbar-default navbar-static-top navbar-sticky" role="navigation">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-responsive-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div id="navbar-spy" class="collapse navbar-collapse navbar-responsive-collapse">
<ul class="nav navbar-nav pull-right">
<li>
<a href="<?php echo site_url(); ?>">About Us</a>
</li>
<li>
<a href="<?php echo site_url('welcome/support_us'); ?>">Support Us</a>
</li>
<li class="active dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Newsletter</a>
<ul class="nav navbar-nav pull-right dropdown-menu" role="menu">
<li><a href="<?php echo site_url('welcome/tam_newsletter'); ?>">Tamil Newsletter</a></li>
<li><a href="<?php echo site_url('welcome/eng_newsletter'); ?>">English Newsletter</a></li>
</ul>
</li>
<li>
<a href="<?php echo site_url('welcome/gallery'); ?>"><span>Gallery</span></a>
</li>
<li>
<a href="<?php echo site_url('welcome/contact_us'); ?>"><span>Contact Us</span></a>
</li>
</ul>
</div>
</div>
</nav>
一旦我实现了移动(&amp;&amp;)版本,它就是唯一一个被调用的版本。我试图通过以下单元测试。
std::pair<iterator, bool> insert(value_type const& pair);
std::pair<iterator, bool> insert(value_type&& pair);
但它正在呼唤&amp;&amp;功能不是const&amp;一。不确定为什么const&amp;永远不会被称为。
如果我删除&amp;&amp;实现const&amp;被叫,我通过了单元测试。
使用以下内容会产生什么副作用:
using mapped_t = std::string;
using vector_t = std::vector<mapped_t>;
using trie_t = trie<mapped_t>;
using key_t = trie_t::key_type;
using map_t = std::map<key_t, mapped_t>;
vector_t data{ "nine", "ten", "seven", "eight", "five", "six", "three", "four", "one", "two" };
map_t m;
trie_t t;
for (auto datum : data) {
t.insert(trie_t::value_type(datum, datum));
m.insert(map_t::value_type(datum, datum));
}
BOOST_CHECK(std::equal(t.begin(), t.end(), m.begin()));
BOOST_CHECK(t.size() == m.size());