strong_type | An additive strong typedef library for C++14/17/20
kandi X-RAY | strong_type Summary
kandi X-RAY | strong_type Summary
Jonathan Boccara from MeetingC++ 2017. Barney Dellar from C++OnSea 2019. Björn Fahller from ACCU 2018. Adi Shavit & Björn Fahller from NDC{Oslo} 2019. Discussions, pull-requests, flames are welcome.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of strong_type
strong_type Key Features
strong_type Examples and Code Snippets
Community Discussions
Trending Discussions on strong_type
QUESTION
I created a struct with two static functions for testing purposes. The first instance of f
is called when an l-value reference
is passed. The second instance is called when an r-value
is passed:
ANSWER
Answered 2018-Nov-19 at 17:57The difference is not due to using an alias (using
), but to the type you pass as first template argument to create_strong_type
. In one case, it's an int
, and in the other, a double
.
Try T::f(KG(4.2)());
and you will see the argument is passed as lvalue reference (because of the return type of Strong_Type::operator()
, which is T&
).
QUESTION
I am trying to implement functionality similar to boost/operators.
Here is what I have so far:
...ANSWER
Answered 2018-Oct-12 at 15:37template
struct strong_add {
friend D operator+( D lhs, D const& rhs ) {
lhs += rhs; return lhs;
}
friend D& operator+=( D& lhs, D const& rhs ) {
lhs.v += rhs.v;
return lhs;
}
};
struct myint :
strong_type,
strong_add {
using strong_type::strong_type;
};
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install strong_type
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page