On 14 November 2012 19:04, doug livesey <biot...@gmail.com> wrote: > Hi -- I'm trying to implement persistence with SOCI in a C++ project I'm > working on, but am coming a little unstuck when saving models that need to > know their parent's id for persistence. Which is most of the objects! > I've tried creating a std::pair (with child and parent domain classes) > specialisation for the type_conversion template, and this does work, but it > requires me to either relax security on my models, or to create a > specialisation for const and non-const members.
Generally, that's the way things work with templates. Although, you have choices to avoid code duplicate: - use two different types/names: const_mytype and mytype - use inheritance, as (counter-intuitively) non-const operations are specialisation of const ones, so you can use compile-type polymorphism to hide/block const operations in non-const subtype, and provide non-const version of operation - use template specialisation (a canonical way (?)). Sorry, I'm not really able to give any in-depth insights. Best regards, -- Mateusz Loskot, http://mateusz.loskot.net ------------------------------------------------------------------------------ Monitor your physical, virtual and cloud infrastructure from a single web console. Get in-depth insight into apps, servers, databases, vmware, SAP, cloud infrastructure, etc. Download 30-day Free Trial. Pricing starts from $795 for 25 servers or applications! http://p.sf.net/sfu/zoho_dev2dev_nov _______________________________________________ soci-users mailing list soci-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/soci-users