列表 第页
C ++ 11有两个新的字符串转换函数为无符号长和很长很长:的std :: stoul()和的std ::斯托尔()。C++11 has two new string conversion functions into unsigned long and long long: std::stoul() and st...阅读全文
我工作的一个kd树实现和我目前使用的的std :: nth_element 作为分区由他们中间元素的载体。然而性病:: nth_element需要90%的树结构的时间。任何人都可以提出一个更有效率的选择?I'm working on a kd-tree implementation and I'm currently...阅读全文
我有一个链表实现,我尝试用两种归并和快速排序算法。I have a linked list implementation and I'm experimenting with both Mergesort and QuickSort algorithms.我不明白的是为什么的std ::列表排序操作是如此之快。看...阅读全文
在学习有关对齐的问题等等,我意识到,我的实现G ++ 4.9(MacPorts的OS X)不具有的std ::对齐支持。如果我尝试编译(用 -std = C ++ 11 )的http://www.cplusplus.com/reference/memory/align/While learning about ali...阅读全文
的的std ::矢量的实施随Visual Studio 2010和更早版本有一个众所周知的特殊性:在调整方法具有以下特征(C ++ 03标准):The implementation of std::vector that ships with Visual Studio 2010 and earlier versio...阅读全文
试行的std :: TR1的::数组在Mac上我得到16字节对齐。 的sizeof(INT)= 4;的sizeof(性病:: TR1的::数组< INT,3>)= 16;的sizeof(性病:: TR1的::数组< INT,4>)= 16;的sizeof(性病:: TR1的::数组<...阅读全文
我试图写一个解决办法this问题通过提供不同的和人工的方式来计算一个均值和std 的。 I was trying to write a solution for this question by providing a different and a manual way to calculate a mean an...阅读全文
我有一些成员一个结构,我有一个实现运营商==它。是否安全,实现运营商LT;与==操作符的帮助?我想用这个结构在一组,而我要检查这个结构是独一无二的。I have a struct with some members and I have an implemented operator== for it. Is i...阅读全文
我想使用的std :: equal_range 的结构下面我有编译错误,指出错误:不对应的'运营商的LT; 。 I am trying to use std::equal_range with the structure below I have compilation error saying that error...阅读全文
有关比如std ::地图的地图,我怎么积累它的价值之和?其实,我有一个仿函数和std :: for_each的算法,使得它。但我也想使这个使用std ::累积算法。我不知道如何应用它到std ::地图。这甚至可能?结构Accumurator:的std :: unary_function<的std ::对&L...阅读全文
我怎样才能有效地选择一个随机元素的std ::设为?How can I efficiently select a random element from a std::set?A 的std ::设置:迭代是双向迭代器。所以我不能直接指数随机选取的元素像我所能为的std :: deque的或的std ::矢量 A s...阅读全文
鉴于布尔值的容器(一个例子是的std ::矢量<布尔> ),是否有一个标准的函数,返回真如果所有的值真(和)或者真如果至少有一个价值是真(或),短路evalutation?Given a container of boolean values (An example is std::vector
我想删除从的std ::列表元素和保留已删除元素的一些统计数据。I am trying to remove elements from a std::list and keep some stats of deleted elements.为了做到这一点,我使用的remove_if函数从列表中,我有一个predic...阅读全文
跟进这一问题的讨论,我不知道如何来使用本机C ++编程方式确定与否的标准::字符串实现他们使用的是开发前景的的副本上写(COW)的 Following up on the discussion from this question, I was wondering how does one using native...阅读全文
我有一个的std ::矢量< INT> 和第二容器保持迭代器或索引(无钥匙,我要不断的访问元素)这个载体为删除的目的。让我们假设我有1000个元素的向量和要删除其中的200。非移除元素的顺序应该是删除操作后的同一像以前一样。i have a std::vector and a secon...阅读全文
在C ++ 11标准保证了的std ::排序拥有的为O(n LOGN)的复杂性 在最坏的情况下。这是从平均情况不同保证在C ++ 98/03,其中的std ::排序可与快速排序(也许联合实施与插入排序对于小的n),它在最坏的情况下为O(n ^ 2)(对于某些特定输入,如排序输入)。The C++11 standard...阅读全文
我有一个塔容器类型:struct MyColumnType { // Data: Each row represents a member of an object.vector a; // All vectors are guaranteed to have alwaysvector
我写了一个类来充当围绕顺序容器(的std ::矢量 / 的std ::队列 / 的std ::列表)有一个的std ::地图,性能在使用小接口小物件的数量。编码一切都非常简单因为已经存在的算法。这code是明显的高的从我的全code修整,但显示了问题。I wrote a class to act as a wrapp...阅读全文
我一直认为的std :: LOWER_BOUND()运行在对数时间,如果我通过了一双红黑树迭代器(集::迭代器或图:迭代)给它。我不得不把自己烧得两次注意到的std :: LOWER_BOUND()在O(n)的运行时间在这种情况下,至少用libstdc ++实现。据我所知,标准不具有红黑树迭代器的概念; 的std ::...阅读全文
我的std :: string是UTF-8 EN codeD如此明显,str.length()返回错误的结果。我发现这个信息,但我不知道我怎么可以用它来做到这一点:下面的字节序列用于重新present一个字符。该序列是使用取决于字符的UCS code号:00000000 - 0x0000007F:0xxxxxxx0...阅读全文
做流行的C ++编译器使用的std ::排序和std :: stable_sort什么算法?我知道这个标准只给出了一定的性能要求,但我想知道哪些算法实现普及在实践中使用。What algorithms do popular C++ compilers use for std::sort and std::stable...阅读全文
我想从这个问题 C ++性病的code: :?变换()和toupper()..why这是否失败 #include #include int main() {std::string s="hello";std::string out;std::transform(s.begi...阅读全文
pop() 函数有什么问题为什么不能正常工作?What is wrong with the pop() function why doesn't it work correctly?class stack{int *p, *Cursor;int size ;public:stack(int sz) {Cursor...阅读全文
我使用Eclipse来开发Android应用程序也使用NDK。我向量我的应用程序,我已经做了必要的东西,通过包括让他们 APP_STL:= stlport_static 在我的Application.mk 一切工作正常它编译和运行,但是Eclipse不断给我的错误,当我使用了矢量 的std ::矢量<&INT G...阅读全文
我如何咚任意函数的参数任意(固定的)数字,在x86和x64?How do I thunk an arbitrary function with an arbitrary (fixed) number of arguments, on x86 and x64?(我不需要浮点,SSE,等等。这些参数都是整数或指针。)...阅读全文
考虑以下code template void foo(std::bitset bs){ /* whatever */ }int main(){bitset bar;foo(bar);return 0;}G ++这个在64位抱怨,因为在< 8>得到PTED为uns...阅读全文
我的代码void build(std::vector& roots, ...) {try {// using a local lock_guard to lock mtx guarantees unlocking on destruction / exception:std...阅读全文
std::sync::atomic::AtomicBool 的所有方法 采用我以前没有使用过的内存排序(Relaxed、Release、Acquire、AcqRel 和 SeqCst).在什么情况下应该使用这些值?该文档使用了我不太了解的令人困惑的加载"和存储"术语.例如:All the methods of std...阅读全文
我正在使用 gcc 4.6.假设有一个参数向量 v 我必须传递给可变参数函数 f(const char* format, ...).I'm using gcc 4.6.Assume that there is a vector v of parameters I have to pass to a variad...阅读全文
在 c++ 中如何打印堆栈的内容并返回其大小?In c++ how can I print out the contents of my stack and return its size?std::stack values;values.push(1);values.push(2);values...阅读全文
标准是否保证以下代码可以工作(假设 st 不为空)?Is the following code guaranteed by the standard to work(assuming st is not empty)?#include #include int main(){ex...阅读全文
我正在编写一个非常简单的 std::stack ,使用向量作为其底层容器.我意识到我可以用向量容器的 push_back()、pop_back() 和 back() 替换所有的 push()、pop() 和 top() 函数.I am writing a very simple std::stack using ve...阅读全文
void PDA::parse(vector words){for(int i=0; i
std::array(我自己不使用 new)是否保证被 C++ 标准分配在堆栈中而不是堆中?Is std::array (without myself using new) guaranteed to be allocated in the stack rather then the...阅读全文
这确实是一个仅出于我自己的兴趣的问题,我无法通过文档确定.This really is a question just for my own interest I haven't been able to determine through the documentation. 我在 http://www.cplu...阅读全文
如何在 std::string 中存储敏感数据(例如:密码)?How does one store sensitive data (ex: passwords) in std::string?我有一个应用程序,它提示用户输入密码并在连接设置期间将其传递给下游服务器.我想在建立连接后安全地清除密码值.I have...阅读全文
我想在我的Android应用程序中使用一个大的C ++库。我使用的Eclipse与Android NDK的插件。当我运行它,我得到这个错误信息; I am trying to use one big c++ library in my android application. I am using eclipse...阅读全文
我遇到了 dynamic_cast 的问题.我刚刚编译了我的项目并在调试模式下测试了所有东西,然后我尝试在发布模式下编译它,我已经从调试模式 exept 优化参数复制了每个配置,现在是/o2,(在调试时我将它设置为/od)项目已编译,但当它开始加载我的资源时,我在此处的代码段中遇到异常:I'm having prob...阅读全文