[ create a new paste ] login | about

Link: http://codepad.org/RYv7U02r    [ raw code | output | fork ]

hendrix.john64@gmail.com - C++, pasted on Jul 27:
#include <iostream>
#include <string>
using namespace std;

class Hokey
{
public:
    explicit Hokey(int i): i_(i) { }

    template<typename T>
    T& render(T& t) { t = static_cast<T>(i_); return t; }
private:
    unsigned i_;
};

int main()
{
    Hokey h(1);
    string str;
    h.render(str);
    cout << "str = " << str << endl;
    return 0;
}


Output:
1
2
3
4
t.cpp: In member function 'T& Hokey::render(T&) [with T = std::string]':
t.cpp:21:   instantiated from here
Line 11: error: no matching function for call to 'std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(unsigned int&)'
compilation terminated due to -Wfatal-errors.


Create a new paste based on this one


Comments: