Skip to content

amarmer/String-Proxy-Puzzle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

String Proxy Puzzle

Published in https://isocpp.org/blog/2018/10/string-proxy-puzzle

C-style string cannot be used as a template parameter (X<"abc">() won't compile).
It is possible for any C-style string to use it's proxy as a template parameter and reconstruct the compile-time string from it. Program below demonstrates it. Code can be modified only in the places where PUZZLE is.

// No headers

template <typename T> 
constexpr auto StringProxy()
{
  PUZZLE 
}

static_assert(StringProxy<PUZZLE>() == "StringProxy");
                                                           
int main() { return 0; }

There are 2 solutions (compile on Clang and GCC C++17): solution and solution.

About

String Proxy Puzzle

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages