1 /** testpolymorph.cpp --- A sequence of polymorphism examples.
3 * Copyright (C) 2009-2015 Free Software Foundation, Inc.
5 * Author: Eric M. Ludlam <eric@siege-engine.com>
7 * This file is part of GNU Emacs.
9 * GNU Emacs is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * GNU Emacs is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
25 // Test 1 - Functions w/ prototypes
28 int pt_func1(int arg1
);
29 int pt_func1(int arg1
) {
35 // Test 2 - Functions w/ different arg lists.
47 int pm_func(double a
) {
53 // Test 3 - Methods w/ different arg lists.
65 int pm_meth(double a
) {
71 // Test 4 - Templates w/ partial specifiers.
72 namespace template_partial_spec
{
73 template <typename T
> class test
76 void doSomething(T t
) { };
79 template <typename T
> class test
<T
*>
82 void doSomething(T
* t
) { };
86 // Test 5 - Templates w/ full specialization which may or may not share
88 namespace template_full_spec
{
89 template <typename T
> class test
92 void doSomething(T t
) { };
93 void doSomethingElse(T t
) { };
96 template <> class test
<int>
99 void doSomethingElse(int t
) { };
100 void doSomethingCompletelyDifferent(int t
) { };
104 // Test 6 - Dto., but for templates with multiple parameters.
105 namespace template_multiple_spec
{
106 template <typename T1
, typename T2
> class test
109 void doSomething(T1 t
) { };
110 void doSomethingElse(T2 t
) { };
113 template <typename T2
> class test
<int, T2
>
116 void doSomething(int t
) { };
117 void doSomethingElse(T2 t
) { };
120 template <> class test
<float, int>
123 void doSomething(float t
) { };
124 void doSomethingElse(int t
) { };
125 void doNothing(void) { };
130 // End of polymorphism test file.