Debian Codegraph @

test/typeparam/issue50193.go

raw
1 // run
2
3 // Copyright 2021 The Go Authors. All rights reserved.
4 // Use of this source code is governed by a BSD-style
5 // license that can be found in the LICENSE file.
6
7 package main
8
9 import (
10 "fmt"
11 )
12
13 type Complex interface {
14 ~complex64 | ~complex128
15 }
16
17 func zero[T Complex]() T {
18 return T(0)
19 }
20 func pi[T Complex]() T {
21 return T(3.14)
22 }
23 func sqrtN1[T Complex]() T {
24 return T(-1i)
25 }
26
27 func main() {
28 fmt.Println(zero[complex128]())
29 fmt.Println(pi[complex128]())
30 fmt.Println(sqrtN1[complex128]())
31 fmt.Println(zero[complex64]())
32 fmt.Println(pi[complex64]())
33 fmt.Println(sqrtN1[complex64]())
34 }
35