Franny's Adobe

Il blog di Francesco Carucci
posts - 99, comments - 612, trackbacks - 937

C++/CLI, mai piu' senza...

Da qualche settimana sto giocando con C++/CLI, perche' e' proprio come un bel giochino nuovo. Lo affronto dal lato di quello che vuole imparare le nuove estensioni (ma in realta' e' un linguaggio) senza leggere alcun manuale, facendo esperimenti, come papa' Ron Jeffries ci insegna.

template <typename T>
value class Handle
{
public:

  Handle(T^ t)
  {
      m_GCHandle = GCHandle::Alloc(t);
  }

  void* ToPointer(void)
  {
      IntPtr handle = GCHandle::ToIntPtr(m_GCHandle);
      return handle.ToPointer();
  }

  static T^ ToTarget(void* pointerToTarget)
  {
       return (T^) GCHandle::FromIntPtr((IntPtr) pointerToTarget).Target;
  }

private:  
  GCHandle m_GCHandle;
};

Un template di una value class che accetta un tipo managed. Ma non e' adorabile?

Print | posted on lunedì 26 settembre 2005 18.55 | Filed Under [ Programming ]

Feedback

Gravatar

# re: C++/CLI, mai piu' senza...

non me la ricordavo la cosa dei puntatori a void... O_o
sooooo cute *_*
26/09/2005 23.52 | Marco
Gravatar

# re: C++/CLI, mai piu' senza...

http://www.kodes.com http://www.kitlen.com http://kitlen.com/yonja.php http://sohbet.kitlen.com

Thank you...
17/06/2007 21.21 | sohbet
Gravatar

# sohbet

thanks
25/01/2008 18.55 | sohbet
Gravatar

# re: C++/CLI, mai piu' senza...

THANGYOU http://www.trsohbeti.net http://www.sohbet99.net http://www.muhabbethane.com http://www.nesohbet.com
http://www.mirc10.com http://www.sozsohbet.com
http://oyular.blogspot.com http://mirctr.blogspot.com
26/01/2008 9.45 | oyular

Post Comment

Title  
Name  
Email
Url
Comment   
Please add 1 and 7 and type the answer here:

Powered by: