小编Kon*_*rad的帖子

字符编码混乱!

有一些问题让我了解UTF-8,UTF-16,ASCII和ANSI之间的差异.在做了一些研究之后我有了一些想法,但是如果有人能够准确地解释它们之间的区别(包括每个的典型字符的字节表示),那将非常有用.

我问我的问题归结为

1) How do each of the above store characters as bytes
2) What are the differences between the above standards
3) What is a code page
4) Method of converting characters between the various types.
Run Code Online (Sandbox Code Playgroud)

非常感谢 :)

c++ unicode encoding character

3
推荐指数
1
解决办法
510
查看次数

软件测试时的清洁空间

我想检查我的代码在使用我没有代码的其他库时的操作方式.虽然我可以在线进行此操作(即使用来自SysInternals的FileMon,RegMon和TCPView),但我想知道是否有一个好的离线方法可以让我在虚拟机中运行我的代码,关闭虚拟机并使整个差异化虚拟机映像?

testing code-analysis stress-testing

3
推荐指数
2
解决办法
253
查看次数

拆分已经拆分的窗格 (MFC)

在我的 MFC 程序中,我使用拆分器来创建两个窗格。我现在想再次将这些窗格中的一个分成两半并放入另一个视图,有人可以告诉我如何做或指向一些代码的方向吗?

我更喜欢自己编写代码,所以我对自定义派生类不感兴趣,除非它们非常基础。

谢谢!

c++ mfc views splitter

2
推荐指数
1
解决办法
2202
查看次数

MFC:更改List控件的字体

我需要在运行时更改列表控件的字体,以便使用固定宽度的字体.我看到一些例子表明我应该捕获NM_CUSTOMDRAW消息,但我想知道是否有更好的方法.

谢谢.

c++ mfc messages visual-c++

2
推荐指数
1
解决办法
8352
查看次数

STL迁移问题(VS 2003 - > 2005)

我刚刚将一个项目从Visual Studio 2003转换为2005,虽然它的大部分"转换"很好,但我从以下行得到了一系列STL错误:

void SomeFn( std::vector<CSomeObject*>::iterator it,
std::vector<CSomeObject*>::iterator itBegin = NULL,
std::vector<CSomeObject*>::iterator itEnd = NULL );
Run Code Online (Sandbox Code Playgroud)

Visual Studio错误如下:

c:\<path>\Headerfile.h(20) : error C2440: 'default argument' : cannot convert from 'int' to 'std::_Vector_iterator<_Ty,_Alloc>'
        with
        [
            _Ty=CObject *,
            _Alloc=std::allocator<CObject *>
        ]
        No constructor could take the source type, or constructor overload resolution was ambiguous
Run Code Online (Sandbox Code Playgroud)

我看不出该代码有什么问题,它在VS 2003中完美运行.有什么想法吗?

c++ migration iterator stl

2
推荐指数
1
解决办法
477
查看次数

C++ Visual Studio运行时错误

任何人都可以向我解释这意味着什么?

"运行时检查失败#0 - ESP的值未在函数调用中正确保存.这通常是调用使用一个调用约定声明的函数,其中函数指针使用不同的调用约定声明."

c++ debugging visual-studio

2
推荐指数
1
解决办法
2080
查看次数

返回迭代器

我有一个函数,它搜索STL容器然后在找到位置时返回迭代器,但是我得到一些有趣的错误消息,可以告诉我我做错了什么?

功能:

std::vector< CClass >::iterator CClass::SearchFunction( const std::string& strField )
{
...

   return it;

...
}
Run Code Online (Sandbox Code Playgroud)

错误:

error C2664: 'std::_Vector_iterator<_Ty,_Alloc>::_Vector_iterator(const std::_Vector_iterator<_Ty,_Alloc> &)' : cannot convert parameter 1 from 'std::_Vector_const_iterator<_Ty,_Alloc> *__w64 ' to 'const std::_Vector_iterator<_Ty,_Alloc> &'
Run Code Online (Sandbox Code Playgroud)

c++ iterator stl

2
推荐指数
1
解决办法
1万
查看次数

原位删除元素的最佳方法

我有一组迭代的对象,但是我可以在迭代期间决定现在需要删除其中一个(或多个)对象.

我的代码如下:

if( ! m_Container.empty() )
    {
        for(  typedefedcontainer::iterator it = m_Container.begin();
              it != m_Container.end(); 
              ++it  )
        {
            if( ! ( SomeFunction( (*it), "test", "TEST!", false ))  )
            {
            // If function returns false, delete object.
                m_Container.erase( it );
                AsyncResponseStore::iterator it = m_asyncResponses.begin();
            }

        }


    }
Run Code Online (Sandbox Code Playgroud)

但是当然,当我擦除一个对象时,我得到一个错误:"Map/set iterator not incrementable".有人可以建议一个更好的方法吗?

请参阅: 如果在从开始到结束迭代时调用map元素上的erase()会发生什么?

c++ stl set

2
推荐指数
2
解决办法
1355
查看次数

使用STL迭代器而不初始化它

我想做这样的事情:

container::iterator it = NULL;

switch ( eSomeEnum )
{
case Container1:
it = vecContainer1.begin();
break;

case Container2:
it = vecContainer2.begin();
break;
...


}

for( ; it != itEnd ; ++it )
{ 
..
}
Run Code Online (Sandbox Code Playgroud)

但是我无法创建迭代器并将其初始化为NULL.有什么方法可以做到这一点吗?理想情况下,我只是在交换机中创建并分配迭代器,但它会立即超出范围.

c++ iterator scope stl

2
推荐指数
2
解决办法
855
查看次数

优化迭代器定义

这是一个(希望)非常简单的问题 - 我最近被告知使用C++样式初始化比传统(和更常见)的分配更好.

所以这段代码:

std::SomeSTLContainer::const_iterator it = container.begin();
std::SomeSTLContainer::const_iterator itEnd = container.end();
Run Code Online (Sandbox Code Playgroud)

比以下更慢或效率更低:

std::SomeSTLContainer::const_iterator it ( container.begin() );
std::SomeSTLContainer::const_iterator itEnd ( container.end() );
Run Code Online (Sandbox Code Playgroud)

我理解这个的原因 - 第一个例子导致默认构造和初始化然后是后续分配,而不是第二个例子中的特定构造和直接分配.但是,在现代处理器/编译器上,它真的有所作为吗?

c++ optimization iterator stl

2
推荐指数
1
解决办法
207
查看次数