Skip to content

Instantly share code, notes, and snippets.

@yohhoy
Created Nov 15, 2017
Embed
What would you like to do?
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