Comments (1)
w.r.t. why the operators are hidden:
linalg.h
was born because I and five-ish of my peers were all in the habit of writing some sort of new "vecmath.h" type header for every project we started, and they were usually about ~80% compatible with one another by default, but just different enough to make code sharing hard. I wanted to see if I could come up with something that would be good enough that we'd all just use it and stop bikeshedding, and it kinda worked for that purpose.
In a few of these codebases, cout << float3{1,2,3}
would print something like <1,2,3>
or (1 2 3)
, etc., and I settled on {1,2,3}
as a halfways decent pretty-print, because it prints the same text that would be required to initialize the float3
via an expression of literals in your source code.
However, a few of these codebases defined cout << float3{1,2,3}
to print 1 2 3
, with an equivalent cin >> v
that allowed you to use the ostream/istream overloads for extremely basic serialization to and from text files (you can kinda half-ass an OBJ loader this way, for instance).
I wanted to permit users to define their own overloads in the global namespace if they had a preference, but still provide an easy alternative that they could opt into if they wanted. This required placing my versions of the overloads in a different namespace than linalg
, so that you could bring them into scope manually but they wouldn't bind tighter than something a user had defined themselves.
As you've discovered, this was not a particularly excellent design choice, and the ostream operator breaks frequently enough that I've seen a number of users just give up and define their own overloads in their respective namespaces.
I don't have much time to maintain this library these days, but I might tweak the documentation over the weekend to recommend your fix.
from linalg.
Related Issues (20)
- Reduction functions for matrices? HOT 2
- Identity() HOT 3
- User Code Extensions HOT 3
- Undefined behavior on operator[] overload prevents use in constexpr context HOT 3
- Fix semantics of operator overloads on matrices. HOT 4
- Finish documentation for `v3` branch. HOT 1
- Impossible to create row vectors HOT 5
- Question about column order. HOT 1
- Doesn't build on MSVC 2017 HOT 3
- Future usability wishlist HOT 4
- `mul()` gives wrong answer? HOT 1
- Feature request: Disable operator * for matrices? HOT 2
- Initializing a std::array of vecs HOT 3
- glm::lookAt equivalent? HOT 10
- Suggestion: projection_onto() and rejection_from() functions for vectors HOT 1
- Convert a mat4 to a mat3 and back
- Compilation with clang fails on OS X (error: ambiguous call to std::abs()) HOT 1
- rotation_quat fails in some cases HOT 8
- avoid GCC -Wshadow warnings? HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from linalg.