From 1f217e38f7507758da1d33d46e675e801621aa38 Mon Sep 17 00:00:00 2001 From: Michael Shepanski Date: Thu, 30 Oct 2014 15:21:32 +1100 Subject: Allow lambdas & std::functions as query factories with C++-98 builds of libodb --- odb/details/function-wrapper.ixx | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 odb/details/function-wrapper.ixx (limited to 'odb/details/function-wrapper.ixx') diff --git a/odb/details/function-wrapper.ixx b/odb/details/function-wrapper.ixx new file mode 100644 index 0000000..58ede04 --- /dev/null +++ b/odb/details/function-wrapper.ixx @@ -0,0 +1,47 @@ +// file : odb/details/function-wrapper.ixx +// copyright : Copyright (c) 2009-2014 Code Synthesis Tools CC +// license : GNU GPL v2; see accompanying LICENSE file + +namespace odb +{ + namespace details + { + template + inline function_wrapper:: + ~function_wrapper () + { + if (deleter != 0) + deleter (std_function); + } + + template + inline function_wrapper:: + function_wrapper (F* f) + : function (f), deleter (0), std_function (0) + { + } + + template + inline function_wrapper:: + function_wrapper (const function_wrapper& x) + : function (0), deleter (0), std_function (0) + { + swap (const_cast&> (x)); + } + + template + inline function_wrapper& function_wrapper:: + operator= (const function_wrapper& x) + { + swap (const_cast&> (x)); + return *this; + } + + template + inline function_wrapper:: + operator bool_convertible () const + { + return function != 0 ? &function_wrapper::true_value : 0; + } + } +} -- cgit v1.1