Template error when declaring function body outside the class body

 

Hello everyone. 

Compiling this code I am getting the following error: "function 'Test::test' already defined and has different return type"

template<typename any>
struct Optional {
    any value;
};

class Test {
public: 

    template<typename any>
    Optional<any>    test();

};

template<typename any>
Optional<any> Test::test() {
    return Optional<any>();
}
But, if I write the function body inside the class I get no error:

template<typename any>
struct Optional {
    any value;
};

class Test {
public: 

    template<typename any>
    Optional<any> test() {
        return Optional<any>();
    }

};
Could someone help me to understand how to solve this problem? (I don't want to mark the whole class as template)