std

Need help applying MinGW patches for std string, getting unexpected ends

荒凉一梦 提交于 2019-12-13 02:54:25
问题 I'm trying to apply these patches: http://tehsausage.com/mingw-to-string So that I can use std string stuff that I should have access to anyways. I have MinGW 4.7.2, and at first, I tried copying the zip files with no luck. Now I'm trying to manually apply the patches. I copied the patch information into a file.patch, placed it in the same folder as the file I am patching, and ran patch < file.patch and then I get: patching file stdio.h patch unexpectedly ends in middle of line Hunk #1 FAILED

'mem_fun' : is not a member of 'std'

断了今生、忘了曾经 提交于 2019-12-13 02:26:45
问题 I've been experiencing this error for a while now, on every project that I have built with the CryEngine2 SDK in Visual Studio 2013 Professional. Most of the time, I have just edited the function from this: void CMultipleGrabHandler::Reset() { std::for_each (m_handlers.begin(), m_handlers.end(), std::mem_fun (&CBaseGrabHandler::Reset)); std::vector <CAnimatedGrabHandler*>::iterator it = m_handlers.begin(); std::vector <CAnimatedGrabHandler*>::iterator end = m_handlers.end(); for ( ; it != end

Calling destructor with decltype and\or std::remove_reference

丶灬走出姿态 提交于 2019-12-12 21:17:48
问题 Is it possible to call destructor(without operator delete) using decltype and\or std::remove_reference? Here's an example: #include <iostream> #include <type_traits> using namespace std; class Test { public: Test() {} virtual ~Test() {} }; int main() { Test *ptr; ptr->~Test(); // works ptr->~decltype(*ptr)(); // doesn't work ptr->~std::remove_reference<decltype(*ptr)>::type(); // doesn't work return 0; } 回答1: You can use an alias template to get an unqualified type name when all you have is a

C++ random access iterators for containers with elements loaded on demand

て烟熏妆下的殇ゞ 提交于 2019-12-12 16:05:15
问题 I'm currently working on a small project which requires loading messages from a file. The messages are stored sequentially in the file and files can become huge, so loading the entire file content into memory is unrewarding. Therefore we decided to implement a FileReader class that is capable of moving to specific elements in the file quickly and load them on request. Commonly used something along the following lines SpecificMessage m; FileReader fr; fr.open("file.bin"); fr.moveTo(120); //

How i can return a std::map containing the differences of two maps in c++?

十年热恋 提交于 2019-12-12 15:28:07
问题 i have two maps and i need to find the differences and create a new map that only has the differences. Not sure how to do this. I tried using set_difference but don't really understand how it works. Any help would be appreciated. thanks // header file typedef std::map<std::string, int> MapCol; typedef std::map<std::string, MapCol> MapRow; MapRow m_mapRows; //.cpp fle CheckForDifferences( const Table& rhs ) { Table diffTable; vector<string> v; vector<string>::iterator it; it=set_difference (m

namespace usage

☆樱花仙子☆ 提交于 2019-12-12 15:05:40
问题 I'm trying to start using namespaces the correct (or at least best) way. The first thing I tried to do was to avoid putting using namespace xxx; at the beginning of my files. Instead, I want to using xxx::yyy as locally as possible. Here is a small program illustrating this : #include <iostream> #include <cstdlib> #include <ctime> int main() { using std::cout; using std::endl; srand(time(0)); for(int i=0; i<10;++i) cout << rand() % 100 << endl; return 0; } If I omit the lines using std::cout;

Constructors : difference between defaulting and delegating a parameter

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-12 14:23:14
问题 Today, I stumbled upon these standard declarations of std::vector constructors : // until C++14 explicit vector( const Allocator& alloc = Allocator() ); // since C++14 vector() : vector( Allocator() ) {} explicit vector( const Allocator& alloc ); This change can be seen in most of standard containers. A slightly different exemple is std::set : // until C++14 explicit set( const Compare& comp = Compare(), const Allocator& alloc = Allocator() ); // since C++14 set() : set( Compare() ) {}

state of std::vector after std::bad_alloc

北城以北 提交于 2019-12-12 11:52:44
问题 I'm trying to find a online reference to see the exception safety of several std containers. In the case of std::vector , Does it keep the state previous to the push_back call? I would presume the vector has all its objects still valid (no destructors invoked). What guarantees offer std::vector after push_back throws a std::bad_alloc exception? 回答1: If it throws, the vector isn't changed. Even not the capacity() . According to [container.requirements.general]: Unless otherwise specified (see

Why is `std::invoke` not constexpr?

只愿长相守 提交于 2019-12-12 10:34:23
问题 Shouldn't std::invoke be constexpr especially after constexpr lambdas in C++17? Are there any obstacles that will prevent this? 回答1: Update: P1065 will make it constexpr . Keep original post for historical reason: From the proposal: Although there is possibility to implement standard conforming invoke function template as a constexpr function, the proposed wording does not require such implementation. The main reason is to left it consistent with existing standard function objects, that could

num_get facet and stringstream conversion to boolean - fails with initialised boolean?

早过忘川 提交于 2019-12-12 09:09:50
问题 I have inherited a template to convert a string to a numerical value, and want to apply it to convert to boolean . I am not very experienced with the stringstream and locale classes. I do seem to be getting some odd behaviour, and I am wondering if someone could please explain it to me? template<typename T> T convertFromString( const string& str ) const { std::stringstream SStream( str ); T num = 0; SStream >> num; return num; } This works fine until I try the boolean conversion string str1(