Skip to content

Instantly share code, notes, and snippets.

@lifely
Created December 17, 2011 20:01
Show Gist options
  • Save lifely/1491210 to your computer and use it in GitHub Desktop.
Save lifely/1491210 to your computer and use it in GitHub Desktop.
This Hell
#ifndef FUNCTION_HPP_
# define FUNCTION_HPP_
#include "../etape1/FunctionSignature.hpp"
#include <iostream>
template <typename T>
class Function
{
public:
Function() { std::cout << "Create Basic" << std::endl; };
~Function(void) { std::cout << "Destroy Basic" << std::endl; };
Function & operator=(T (*func)())
{
this->f = func;
std::cout << "Bidule Shouette" << std::endl;
return this;
};
T operator()()
{ return f(); };
public:
FunctionSignature<T()>f;
};
template<typename T, typename A>
class Function<T(A)>
{
public:
Function(T(A)) { std::cout << "Create Specialized" << std::endl; };
~Function(void) { std::cout << "Destroy Specialized" << std::endl; };
Function<T(A)> & operator=(T (*func)(A))
{
this->f = func;
std::cout << func << std::endl;
return *this;
};
T operator()(A arg)
{ return f(arg); };
public:
T (*f)(A);
};
#endif // !FUNCTION_HPP_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment