boost::multi_index and std::map find() and erase()
boost::multi_index and std::map find() and erase()
是否有可能将boost::multi_index
、find()
和erase()
的方法包装起来,得到类似的std::map
、find()
和erase()
的方法?
[from comments:]我有这个方法:
typename container1::const_iterator find(const K& key) const
{
//typedef typename nth_index<container1,0>::type it; c.get<1>().find(key);
return (???);
}
我应该在返回语句中写什么??
如果我理解你的问题,你想返回一个索引0迭代器,而查找是用索引1完成的,对吗?使用迭代器投影:
template<typename Container, typename Key>
typename Container::const_iterator find(const Container& c, const Key& key)
{
return c.project<0>(c.get<1>().find(key));
}
相关文章:
- C++核心准则 C35 对于接口类"A base class destructor should be either public and virtual, or protected and nonv
- 为什么C++逐位AND运算符在不同大小的操作数中表现为这样
- 为什么 Clang 不允许"and"作为函数名称?
- 位阵列上的快速AND运算
- 是否可以在 C++03 中定义'move-and-swap idiom'等效项
- BoostPython and CMake
- 可视化C++:发布模式的运行时库作为'Multi-threaded Debug DLL'
- OpenSSL BIO and SSL_read
- Gurobi GRBModel and GRBmodel in C++
- std::visit and std::variant usage
- SHBrowseForFolder with BIF_BROWSEFORCOMPUTER and SHGetPathFr
- Directx12 and keystrokes
- different between int **arr =new int [ n]; and int a[i][j]?
- C++ getenv and setenv
- Inference pytorch C++ with alexnet and cv::imread image
- Visual Studio 2019 C++ and std::filesystem
- 保证逻辑 AND 表达式中的函数调用
- python ctypes and C++ pointers
- C++ const char with .begin() and .end()
- Threads with Classes and std::packaged_task