Skip to content

Instantly share code, notes, and snippets.

@ldionne
Created December 13, 2021 17:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ldionne/7ec0a1f4bd4e110ef72aff5021c529a2 to your computer and use it in GitHub Desktop.
Save ldionne/7ec0a1f4bd4e110ef72aff5021c529a2 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
cat <<EOF | clang++ -xc++ - -c -o string.o
template <class T>
struct basic_string {
__attribute__((internal_linkage))
void shrink_to_fit();
};
template <class T>
void basic_string<T>::shrink_to_fit() { }
template class basic_string<char>;
EOF
cat <<EOF | clang++ -xc++ - -c -o main.o
template <class T>
struct basic_string {
__attribute__((internal_linkage))
void shrink_to_fit();
};
template <class T>
void basic_string<T>::shrink_to_fit() { }
extern template class basic_string<char>;
int main() {
basic_string<char> s;
s.shrink_to_fit();
}
EOF
clang++ string.o main.o
rm string.o main.o
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment