This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <string> | |
| #include <string_view> | |
| #include <unordered_map> | |
| template<typename T, typename = void> | |
| struct KeyTraits {}; | |
| template<> | |
| struct KeyTraits<std::string, std::string_view> | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Search-and-replaces the given text based on the key/value pairs of an object. | |
| * @param {string} text - Text to search and replace. | |
| * @param {object} object - Replacee/replacement key/value pairs. | |
| * @returns {string} Text after having pieces replaced. | |
| */ | |
| function replaceYall(text, object) { | |
| return Object.keys(object).reduce((text, key) => { | |
| return text.replaceAll(key, object[key]); | |
| }, text); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| Author: Miss Programgamer | |
| This is an example program that illustrates that some compilers (such as vc++ and g++) | |
| ommit volatility for the vptr part of classes. While I do not know the exact wording | |
| of the standard, I know that the intent of the "volatile" qualifier is to make the | |
| compiler ommit various caching optimisations and read a value each time it is needed, | |
| as the qualifier indicates that memory may be changed unpredictably. However, this | |
| principle is not honored for virtual table pointers, at least for the compilers | |
| listed above. |