1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_CLONE_HXX
11 #define INCLUDED_LOTUSWORDPRO_SOURCE_FILTER_CLONE_HXX
19 template<typename U
, U x
>
23 typedef struct { char a
[2]; } no
;
26 static yes
& check_sig(U
*, test
<U
* (U::*)() const, &U::clone
>* = 0);
28 static no
& check_sig(...);
32 value
= sizeof(check_sig
<T
>(0)) == sizeof(yes
)
36 template<typename T
, bool HasClone
>
39 static T
* clone(T
* const other
)
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
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: */