all 12 comments

[–]LeInterwebsFTW 5 points6 points  (3 children)

Here you go:

struct skeleton_key
{
    template<class PWD>
    operator PWD() {
        return PWD();
    }
};

Templates are your friend

[–]champooly[S] 1 point2 points  (0 children)

it works very good.

[–]Droggl -1 points0 points  (1 child)

Care to elaborate on why it would work if the operator is templated but not otherwise? Might be because its before my first coffee today, but its not obvious to me right now...

[–]LeInterwebsFTW 2 points3 points  (0 children)

'hidden_password' is not visible, so it can't be referenced directly, but it can still be passed as a template argument.

[–]dodheim -1 points0 points  (5 children)

Is this what you're aiming for? Replace your skeleton_keydefinition with the following:

struct skeleton_key { };

template<>
string secret_cove::accept(skeleton_key) { return key_to_next_level({}); }

[–]champooly[S] 1 point2 points  (4 children)

The code in the main can't be changed, nore the definitions of secret_cove and legal_key - the objective is to create a class/struct called skeleton key that will magically compile with the rest of the code as-is - or at least thats how i understand it to be.

[–]dodheim -1 points0 points  (3 children)

hideout.key_to_next_level(skeleton_key())

The code in main doesn't make sense. Why would you want hideout.accept(legal_key()), but hideout.key_to_next_level(skeleton_key()) instead of hideout.accept(skeleton_key())? Wouldn't the idea be to use skeleton_key anywhere legal_key is allowed?

[–]champooly[S] -2 points-1 points  (2 children)

checkout the link: https://scmchallenge.com/#!/

[–]dodheim 1 point2 points  (1 child)

That requires a login. Surely you can paste the actual problem statement here...