Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- void f(const char *&s) {
- std::cout << __PRETTY_FUNCTION__ << '\n';
- }
- template <std::size_t size>
- void f(const char (&s)[size]) {
- std::cout << __PRETTY_FUNCTION__ << '\n';
- }
- template <std::size_t size>
- void f(const char (*s)[size]) {
- std::cout << __PRETTY_FUNCTION__ << '\n';
- }
- void f(const volatile char * s) {
- std::cout << __PRETTY_FUNCTION__ << '\n';
- }
- int main() {
- const char* c = "foo";
- f(c);
- const char*const cc = "foo";
- f(cc);
- f("foo");
- char a[] = "fooington";
- f(a);
- f(&"foo");
- f(&a);
- }
- /****** OUTPUT *********/
- clang++ -std=c++17 -g -Wall -Wextra -pedantic -fsanitize=undefined,address -Wno-unused-parameter -pthread main.cpp && ./a.out
- void f(const char *&)
- void f(const volatile char *)
- void f(const char (&)[size]) [size = 4]
- void f(const char (&)[size]) [size = 10]
- void f(const char (*)[size]) [size = 4]
- void f(const char (*)[size]) [size = 10]
Advertisement
Add Comment
Please, Sign In to add comment