Overview
Features
Download
Documentation
Community
Add-Ons & Services

Implementation of Type Erasure with POCO

A general discussion forum.

Implementation of Type Erasure with POCO

Postby jorgeas80 » 16 May 2014, 11:49

Hello,

I have a class that holds a collection (a vector) as private member. I'd like to find a proper way to allow users of my class iterate over this collection regardless the specific containter I'm using (vector, list, array...).

I've found this useful article, with a proposed implementation of a pattern (Type Erasure) that would solve this issue, but it's based on Boost library, and I don't want to add a new dependency to my project. I'd like to just rely on POCO.

So, does POCO have any implementation of this Type Erasure concept?
the process of turning a wide variety of types with a common interface into one type with that same interface.


I'm using POCO 1.5.1, by the way.

Many thanks in advance.
jorgeas80
 
Posts: 10
Joined: 11 Apr 2014, 15:06

Re: Implementation of Type Erasure with POCO

Postby alex » 16 May 2014, 16:40

If you know upfront how to get your types out later, use Poco::Any (port of boost::any); otherwise, for full conversion capabilities use Poco::Dynamic::Var (essentially, Poco::Any with conversion capabilities).
alex
 
Posts: 1158
Joined: 11 Jul 2006, 16:27
Location: United_States

Re: Implementation of Type Erasure with POCO

Postby jorgeas80 » 16 May 2014, 16:46

Just what I was looking for. Thanks!
jorgeas80
 
Posts: 10
Joined: 11 Apr 2014, 15:06


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest