source: libcfa/src/math.trait.hfa @ e4d7c1c

ADTast-experimental
Last change on this file since e4d7c1c was 7d7ef6f, checked in by Andrew Beach <ajbeach@…>, 3 years ago

Revereted some changes and added a fix to get around the current issue (traits can't refer to traits with the same polymorphic arguments).

  • Property mode set to 100644
File size: 1.3 KB
RevLine 
[08bc3e7]1//
2// Cforall Version 1.0.0 Copyright (C) 2016 University of Waterloo
3//
4// The contents of this file are covered under the licence agreement in the
5// file "LICENCE" distributed with Cforall.
6//
7// math.trait.hfa --
8//
9// Author           : Peter A. Buhr
10// Created On       : Fri Jul 16 15:40:52 2021
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Tue Jul 20 17:47:19 2021
13// Update Count     : 19
14//
15
16#pragma once
17
[7d7ef6f]18trait Not( U ) {
19        void ?{}( U &, zero_t );
20        int !?( U );
[08bc3e7]21}; // Not
22
23trait Equality( T | Not( T ) ) {
24        int ?==?( T, T );
25        int ?!=?( T, T );
26}; // Equality
27
[7d7ef6f]28trait Relational( U | Equality( U ) ) {
29        int ?<?( U, U );
30        int ?<=?( U, U );
31        int ?>?( U, U );
32        int ?>=?( U, U );
[08bc3e7]33}; // Relational
34
35trait Signed( T ) {
36        T +?( T );
37        T -?( T );
38        T abs( T );
39}; // Signed
40
[7d7ef6f]41trait Additive( U | Signed( U ) ) {
42        U ?+?( U, U );
43        U ?-?( U, U );
44        U ?+=?( U &, U );
45        U ?-=?( U &, U );
[08bc3e7]46}; // Additive
47
48trait Incdec( T | Additive( T ) ) {
49        void ?{}( T &, one_t );
50        // T ?++( T & );
[7d7ef6f]51        // T ++?( T & );
[08bc3e7]52        // T ?--( T & );
53        // T --?( T & );
54}; // Incdec
55
[7d7ef6f]56trait Multiplicative( U | Incdec( U ) ) {
57        U ?*?( U, U );
58        U ?/?( U, U );
59        U ?%?( U, U );
60        U ?/=?( U &, U );
[08bc3e7]61}; // Multiplicative
62
63trait Arithmetic( T | Relational( T ) | Multiplicative( T ) ) {
64}; // Arithmetic
65
66// Local Variables: //
67// mode: c //
68// tab-width: 4 //
69// End: //
Note: See TracBrowser for help on using the repository browser.