fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / lotuswordpro / source / filter / clone.hxx
blobbc2f7fb71e84301da64f4ea21ecb18001238d041
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_CLONE_HXX
11 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_CLONE_HXX
13 namespace detail
16 template<typename T>
17 struct has_clone
19 template<typename U, U x>
20 struct test;
22 typedef char yes;
23 typedef struct { char a[2]; } no;
25 template<typename U>
26 static yes& check_sig(U*, test<U* (U::*)() const, &U::clone>* = 0);
27 template<typename U>
28 static no& check_sig(...);
30 enum
32 value = sizeof(check_sig<T>(0)) == sizeof(yes)
36 template<typename T, bool HasClone>
37 struct cloner
39 static T* clone(T* const other)
41 return new T(*other);
45 template<typename T>
46 struct cloner<T, true>
48 static T* clone(T* const other)
50 return other->clone();
56 /** Creates a new copy of the passed object.
57 If other is 0, just returns 0. Otherwise, if other has function
58 named clone with signature T* (T::*)() const, the function is called.
59 Otherwise, copy constructor is used.
61 @returns 0 or newly allocated object
63 template<typename T>
64 T* clone(T* const other)
66 return other ? ::detail::cloner<T, ::detail::has_clone<T>::value>::clone(other) : 0;
69 #endif // INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_CLONE_HXX
71 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */