Some solutions to declare a const ref parameter that does not bind to a temporary.
Compiler-explorer link https://gcc.godbolt.org/z/8Gohnc98f
| #!/usr/bin/bash | |
| # cron entry to run every 30 minutes: */30 * * * * path_to_this_script | |
| # set the path of this script as working directory | |
| cd "$(dirname "$0")" | |
| # ensure that the ssh keys are available in this env | |
| eval `ssh-agent` | |
| # update the readme with current date and weather in rome, and push it | |
| printf "%s\n\`\`\`\n%s\n\`\`\`\n" "$(date)" "$(curl wttr.in/Rome?0T)" > README.md |
Some solutions to declare a const ref parameter that does not bind to a temporary.
Compiler-explorer link https://gcc.godbolt.org/z/8Gohnc98f
| |-TypedefDecl 0x154f310 <<invalid sloc>> <invalid sloc> implicit __int128_t '__int128' | |
| | `-BuiltinType 0x154efb0 '__int128' | |
| |-TypedefDecl 0x154f380 <<invalid sloc>> <invalid sloc> implicit __uint128_t 'unsigned __int128' | |
| | `-BuiltinType 0x154efd0 'unsigned __int128' | |
| |-TypedefDecl 0x154f6f8 <<invalid sloc>> <invalid sloc> implicit __NSConstantString '__NSConstantString_tag' | |
| | `-RecordType 0x154f470 '__NSConstantString_tag' | |
| | `-CXXRecord 0x154f3d8 '__NSConstantString_tag' | |
| |-TypedefDecl 0x154f790 <<invalid sloc>> <invalid sloc> implicit __builtin_ms_va_list 'char *' | |
| | `-PointerType 0x154f750 'char *' | |
| | `-BuiltinType 0x154eab0 'char' |
| all: hello | |
| gcm.cache: | |
| g++ -std=c++20 -fmodules-ts -xc++-system-header iostream | |
| helloworld.o: helloworld.cxx gcm.cache | |
| g++ -std=c++20 -fmodules-ts -c helloworld.cxx -o helloworld.o | |
| hello: helloworld.o | |
| g++ -std=c++20 -fmodules-ts main.cpp helloworld.o -o hello |
| --- | |
| Language: Cpp | |
| # BasedOnStyle: LLVM | |
| AccessModifierOffset: -2 | |
| AlignAfterOpenBracket: Align | |
| AlignConsecutiveAssignments: false | |
| AlignConsecutiveDeclarations: false | |
| AlignEscapedNewlinesLeft: false | |
| AlignOperands: true | |
| AlignTrailingComments: true |
| #include <type_traits> | |
| #include <tuple> | |
| template <typename T> struct is_pair : public std::false_type {}; | |
| template <typename T1, typename T2> | |
| struct is_pair<std::pair<T1, T2>> : public std::true_type {}; | |
| template <typename T> constexpr auto is_pair_v = is_pair<T>::value; | |
| template <typename T, typename = std::void_t<>> |
| // trim from start (in place) | |
| void ltrim(std::string &s) { | |
| s.erase(s.begin(), std::find_if(s.begin(), s.end(), | |
| [](int ch) { return !std::isspace(ch); })); | |
| } | |
| // trim from end (in place) | |
| void rtrim(std::string &s) { | |
| s.erase(std::find_if(s.rbegin(), s.rend(), | |
| [](int ch) { return !std::isspace(ch); }) |
| #include <functional> | |
| #include <memory> | |
| #include <optional> | |
| #include <type_traits> | |
| #include <utility> | |
| namespace lazy { | |
| template <typename T> class DelayProxy { | |
| std::unique_ptr<T> subject{}; |
| #include <string_view> | |
| #include <cstdlib> | |
| #include <ctime> | |
| #include <tuple> | |
| auto str_date = "02/03/88 00:54:56+04"; | |
| using namespace std; | |
| auto parse_time(string_view str_date) -> pair<tm, int>{ | |
| auto next_token = [=, token_pos=0](auto delimiter, bool consume_delimiter = true) mutable{ | |
| token_pos = str_date.find(delimiter, token_pos) + consume_delimiter? 1: 0; |