Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Created November 15, 2017 13:01
Show Gist options
  • Save yohhoy/52b9de2a9f9b3f05b263b5d979013356 to your computer and use it in GitHub Desktop.
Save yohhoy/52b9de2a9f9b3f05b263b5d979013356 to your computer and use it in GitHub Desktop.
std::string_view constructor and UDL (g++7.1 -std=c++1z -O1)
.LC0:
.string "ABCDEFGHIJKLMNOP"
main:
subq $8, %rsp
movl $16, %edi
movl $.LC0, %esi
call sink(std::basic_string_view<char, std::char_traits<char> >)
movl $16, %edi
movl $.LC0, %esi
call sink(std::basic_string_view<char, std::char_traits<char> >)
movl $0, %eax
addq $8, %rsp
ret
#include <string_view>
void sink(std::string_view);
int main() {
sink("ABCDEFGHIJKLMNOP");
using namespace std::literals;
sink("ABCDEFGHIJKLMNOP"sv);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment