![]() ![]() Note that there will be more than 2 types in the application (this was just a short example) and potentially thousands of objects in the file to be read. Throw std::runtime_error( "Unexpected type encountered whilst reading data file." ) VecFutures.emplace_back( std::async( LoadType2, (*itObject).str() ) ) VecFutures.emplace_back( std::async( LoadType1, (*itObject).str() ) ) ![]() ![]() Determine what type of object we're loading: Std::string szFileData( (std::istreambuf_iterator(inFile)), (std::istreambuf_iterator()) ) įor( std::sregex_iterator itObject( szFileData.cbegin(), szFileData.cend(), regexObject ), end itObject != end itObject ) InFile.exceptions( std::ifstream::failbit | std::ifstream::badbit ) = END \\1 =", std::regex_constants::ECMAScript | std::regex_constants::optimize ) Static const std::regex regexObject( "= ( ) = So I was going to define a LoadObject function accepting a std::string for each type of object I'm going to be handling and then calling std::async as follows: void LoadFromFile( const std::string
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |