[ create a new paste ] login | about

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

C++, pasted on Oct 28:
        #include <iostream>
        #include <sstream>

        using std::cout;

        template<class T, int first, int second>
        T make()
        {
            T result = T();
            std::stringstream interpreter;
            interpreter << first << '.' << second;
            interpreter >> result;
            return result;
        }

 template<int first, int second, class T = double>
    struct Make
    {
        typedef T value_type;
        static value_type value;

    };

    template<int first, int second, class T>
    T Make<first,second,T>::value = make<T,first,second>();



    template<int first, int second>
    struct Real
    {
        typedef double type;
        static type value;
    };

        template<int first, int second>
    typename Real<first,second>::type Real<first,second>::value = Make<first,second>::value;  


       int main(int argc, char* argv[])
    {
        cout << Make<1,2>::value << '\n';//UNCOMMENT THIS AND SEE WHAT I MEAN
        cout << Real<1,2>::value;
        return 0;
    }


Output:
1
2
1.2
1.2


Create a new paste based on this one


Comments: