source: src/tests/div.c @ 3b4571b

aaron-thesisarm-ehcleanup-dtorsdeferred_resndemanglerjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerresolv-newwith_gc
Last change on this file since 3b4571b was e1780a2, checked in by Peter A. Buhr <pabuhr@…>, 4 years ago

augment "writable" trait with "ostream" to support more monomorphic IO operations, and add new "div" test using this feature

  • Property mode set to 100644
File size: 1.0 KB
Line 
1//                               -*- Mode: C -*-
2//
3// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
4//
5// The contents of this file are covered under the licence agreement in the
6// file "LICENCE" distributed with Cforall.
7//
8// div.c --
9//
10// Author           : Peter A. Buhr
11// Created On       : Tue Aug  8 16:28:43 2017
12// Last Modified By : Peter A. Buhr
13// Last Modified On : Wed Aug  9 17:09:40 2017
14// Update Count     : 16
15//
16
17#include <fstream>
18#include <stdlib>                                                                               // div
19
20struct T { int i; };
21T ?/?( T t1, T t2 ) { return t1.i / t2.i; }
22T ?%?( T t1, T t2 ) { return t1.i % t2.i; }
23ofstream * ?|?( ofstream * os, T t ) { return os | t.i; }
24
25int main( void ) {
26        sout | "div" | div( 13, 5 ) | div( 13L, 5L ) | div( 13LL, 5LL ) | endl;
27        short s1 = 13, s2 = 5;
28        sout | "div" | div( s1, s2 ) | endl;
29        T t1 = { 13 }, t2 = { 5 };
30        sout | "div" | div( t1, t2 ) | endl;                            // polymorphic div
31} // main
32
33// Local Variables: //
34// tab-width: 4 //
35// compile-command: "cfa div.c" //
36// End: //
Note: See TracBrowser for help on using the repository browser.