It is known that C++ templates are turing complete. As such it should be possible to output a quine that is essentially rendered at compile time. Does anyone know if such a quine has been written yet or where I could find one.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Templates can perform any kind of computation on integer data elements, true. But they aren’t so good at I/O.
What form should the answer take? A template that generates a function that, when executed, outputs the quine source? That’s not really compile time. A template that generates a compile-time list of characters (hundreds or thousands of classes long) composing quine source? Maybe that’s better, but you still need to run the program to output it.
Also, templates are very verbose, and although they are turing complete, that is only within a small memory constraint
guaranteedrecommended by the standard. You can only expect so much recursion, for example, beyond which the program is highly compiler-specific. It might be impossible to write a “meaningfully computed” quine which stores itself in a portable form.