Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Exercise Idea: Template parameter packs #501

Open
JC-13 opened this issue Nov 9, 2021 · 1 comment
Open

New Exercise Idea: Template parameter packs #501

JC-13 opened this issue Nov 9, 2021 · 1 comment

Comments

@JC-13
Copy link

JC-13 commented Nov 9, 2021

With the new v3 concepts I though it would be good to focus more on C++ specific ideas which aren't currently covered in the exercises. Here's some example solution code for the exercise:

#include <iostream>
#include <sstream>

// Should be able to take in any length/ type of arguements
template <typename... Args> std::string concat(Args... args)
{
    std::stringstream output;
    ((output << std::forward<Args>(args) << ","), ...);
    return output.str();
}

int main() {
    std::cout << concat(123, "test") << std::endl;
    // Prints: "123, test,"
    return 0;
}

Wanted to run this by other people before I went and created a whole exercise around it.

Also FYI the "Please see the contributing guide" in the README is a broken link.

@siebenschlaefer
Copy link
Contributor

That sounds like a topic for a "Concept exercise", with some explaining paragraphs and 2-5 simple tasks that would take an experienced C++ programmer 5-15 minutes.
Currently the C++ track has only one of those (https://github.com/exercism/cpp/tree/main/concepts/strings) and IIRC it's not yet live.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants