//
// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
//
// The contents of this file are covered under the licence agreement in the
// file "LICENCE" distributed with Cforall.
//
// polymorphism.c --
//
// Author           : Rob Schluntz
// Created On       : Tue Oct 17 12:19:48 2017
// Last Modified By : Rob Schluntz
// Last Modified On : Tue Oct 17 12:21:07 2017
// Update Count     : 1
//

forall(otype T)
T f(T x, T y) {
	x = y;
	return x;
}

forall(otype T) T ident(T x) {
	return x;
}

int main() {
	// ensure that x is not changed by the invocation of a polymorphic function
	int x = 123;
	int y = 456;
	int z = f(x, y);
	printf("%d %d %d\n", x, y, z);

	// explicitly specialize function
	int (*f)(int) = ident;
	((int(*)(int))ident);
	printf("%d %d\n", f(5), ((int(*)(int))ident)(5));
}

// Local Variables: //
// tab-width: 4 //
// End: //
