Category: Questions and Answers

Question and answers.

vcpkg triplets

Is vcpkg triplet respects CC and CXX env variables and/or CMAKE_C_COMPILER/CMAKE_CXX_COMPILER from CMakePresets? If don't it means that I need to create custom triplet for compiler what I'm using to build my project (clang instead of gcc)? submitted by /u/musialny [link] [comments] * This article was originally published here

Should You Throw an Error or Just Assert for Failed Preconditions? -> Should You Chuck an Error or Just Assert for Failed Preconditions?

Hey guys! Quick question, how do you handle preconditions for public interfaces? Do you use something like std::invalid_argument and asserts? And if so, what do you put in between those throws? Just curious, thanks! submitted by /u/Breezy64267 [link] [comments] * This article was originally published here

How does the rabies virus actually compel the host to bite? How does it know how to tell the brain to bite another living thing?

I find this especially interesting considering the sheer amount of animals that can be infected. Is there one technique or reaction that the virus applies to every brain the same way? Sorry, I’m explaining this very poorly. Hopefully somebody gets the drift šŸ™‚ Thank you kindly in advance. submitted by /u/Lettuce-b-lovely [link] …

Is there a preferred way of accessing a hash data structure in C++

Considering the following code: std::unordered_map<int, int>map1; //check whether an entry exists, if no, insert an entry. Otherwise fetch the entry. if(map1.count(key)){ return map1.at(key); }else{ map1.emplace(key,value); } auto find_result = map1.find(key); if(find_result != map1.end()){ return find_result->second; }else{ map1.emplace(key,value); } auto emplace_result = map1.emplace(key,value); if(emplace_result.second){ return emplace_result.first->second; } I personally feel the last one seems most efficient…