Hi, Is there someway of doing this with Go generics? https://github.com/robaho/cpp_fixed/blob/6770b217acd84e4b723449e4c4bb42c92e7f2af1/fixed.h#L18-L23
I could make the type and interface and add a method for ‘decimal places’, but I would like all of the constants to be resolved at compile time. Also, if I make it an interface, it is far less efficient than passing a single int64 with generics and letting the compiler figure it out. I know constexpr is not available, but I would think that if I could do it with methods the compiler would eventually inline the function calls anyway - possibly as constants. I read through the docs, and it doesn’t seem possible. I got it kind of working here https://go.dev/play/p/5ztum5NAkUp <https://go.dev/play/p/5ztum5NAkUp> but I would really like it to be method based rather than standalone function based, and the method based I would seemingly need to duplicate a lot of code for every possible number of decimal places. What am I missing? Ideas? Thanks for the help. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/3DF3F115-2585-4A8E-A12D-D3375FAE7BF6%40me.com.