
Hello all, Does this Addable concept definition make sense to you? Is there any error? #include <boost/concept_check.hpp> template<typename T> struct Addable { // User-defined concept. BOOST_CONCEPT_USAGE(Addable) { return_type(x + y); // Check addition `T operator+(T x, T y)`. } private: T x; T y; void return_type(T const&); // Used to check addition returns type `T`. }; It's not making Sun's linker happy: "/opt/sunstudio12.1/bin/CC" -g -library=stlport4 -features=tmplife -features=tmplrefstatic -library=stlport4 -m64 -KPIC -o "/scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq" "/scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq.o" -Bdynamic -lrt -Bstatic -Bdynamic Undefined???first referenced symbol ??? in file void Addable<int>::return_type(const int&) /scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq.o ld: fatal: Symbol referencing errors. No output written to /scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq But the error might also be somewhere else in the program that checks the concept, I'm still debugging... Thanks a lot. --Lorenzo -- View this message in context: http://boost.2283326.n4.nabble.com/boost-concept-check-addable-tp4572138p457... Sent from the Boost - Dev mailing list archive at Nabble.com.

on Thu Apr 19 2012, lcaminiti <lorcaminiti-AT-gmail.com> wrote:
Hello all,
Does this Addable concept definition make sense to you?
Well, it "makes sense," but...
Is there any error?
That depends on what concept constraints you're trying to express. This definition tests that x + y is convertible to T.
#include <boost/concept_check.hpp>
template<typename T> struct Addable { // User-defined concept. BOOST_CONCEPT_USAGE(Addable) { return_type(x + y); // Check addition `T operator+(T x, T y)`. }
private: T x; T y;
void return_type(T const&); // Used to check addition returns type `T`. };
It's not making Sun's linker happy:
"/opt/sunstudio12.1/bin/CC" -g -library=stlport4 -features=tmplife -features=tmplrefstatic -library=stlport4 -m64 -KPIC -o "/scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq" "/scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq.o" -Bdynamic -lrt -Bstatic -Bdynamic
Undefined???first referenced symbol ??? in file void Addable<int>::return_type(const int&) /scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq.o ld: fatal: Symbol referencing errors. No output written to /scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq
But the error might also be somewhere else in the program that checks the concept, I'm still debugging...
Thanks a lot. --Lorenzo
-- View this message in context: http://boost.2283326.n4.nabble.com/boost-concept-check-addable-tp4572138p457... Sent from the Boost - Dev mailing list archive at Nabble.com.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Dave Abrahams BoostPro Computing http://www.boostpro.com

Dave Abrahams wrote
on Thu Apr 19 2012, lcaminiti <lorcaminiti-AT-gmail.com> wrote:
Hello all,
Does this Addable concept definition make sense to you?
Well, it "makes sense," but...
Is there any error?
That depends on what concept constraints you're trying to express. This definition tests that x + y is convertible to T.
I wanted to check that there exist an operator+ from T x T to T "T operator+(T, T)" so I think that is what Addable<T> checks... maybe the Sun's linker errors below are from something else (I've changed a regression test to get more info when it cycles tomorrow).
#include <boost/concept_check.hpp>
template<typename T> struct Addable { // User-defined concept. BOOST_CONCEPT_USAGE(Addable) { return_type(x + y); // Check addition `T operator+(T x, T y)`. }
private: T x; T y;
void return_type(T const&); // Used to check addition returns type `T`. };
It's not making Sun's linker happy:
"/opt/sunstudio12.1/bin/CC" -g -library=stlport4 -features=tmplife -features=tmplrefstatic -library=stlport4 -m64 -KPIC -o "/scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq" "/scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq.o" -Bdynamic -lrt -Bstatic -Bdynamic
Undefined???first referenced symbol ??? in file void Addable<int>::return_type(const int&) /scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq.o ld: fatal: Symbol referencing errors. No output written to /scratch2/kbelco/boost/results/boost/bin.v2/libs/local_function/test/typeof_seq.test/sun-5.10/debug/address-model-64/stdlib-sun-stlport/typeof_seq
But the error might also be somewhere else in the program that checks the concept, I'm still debugging...
Thanks, --Lorenzo -- View this message in context: http://boost.2283326.n4.nabble.com/boost-concept-check-addable-tp4572138p457... Sent from the Boost - Dev mailing list archive at Nabble.com.

on Fri Apr 20 2012, lcaminiti <lorcaminiti-AT-gmail.com> wrote:
Dave Abrahams wrote
on Thu Apr 19 2012, lcaminiti <lorcaminiti-AT-gmail.com> wrote:
Hello all,
Does this Addable concept definition make sense to you?
Well, it "makes sense," but...
Is there any error?
That depends on what concept constraints you're trying to express. This definition tests that x + y is convertible to T.
I wanted to check that there exist an operator+ from T x T to T "T operator+(T, T)" so I think that is what Addable<T> checks...
Actually it checks that there exists an operator+ from T non-const lvalue x T non-const lvalue to U, where U is convertible to T const&
maybe the Sun's linker errors below are from something else (I've changed a regression test to get more info when it cycles tomorrow).
I don't know, but it seems unlikely. Probably Sun's linker just needs a body for return_type(). Cheers, -- Dave Abrahams BoostPro Computing http://www.boostpro.com

Dave Abrahams wrote
Actually it checks that there exists an operator+ from T non-const lvalue x T non-const lvalue to U, where U is convertible to T const&
Got it. That works for me but I might change the T non-const lvalue to T const&. For curiosity, is there a way to program the concept ruling out the implicit conversion from U to T const&?
maybe the Sun's linker errors below are from something else (I've changed a regression test to get more info when it cycles tomorrow).
I don't know, but it seems unlikely. Probably Sun's linker just needs a body for return_type().
Indeed that was the case :( --Lorenzo -- View this message in context: http://boost.2283326.n4.nabble.com/boost-concept-check-addable-tp4572138p458... Sent from the Boost - Dev mailing list archive at Nabble.com.

on Mon Apr 23 2012, lcaminiti <lorcaminiti-AT-gmail.com> wrote:
Dave Abrahams wrote
Actually it checks that there exists an operator+ from T non-const lvalue x T non-const lvalue to U, where U is convertible to T const&
Got it. That works for me but I might change the T non-const lvalue to T const&. For curiosity, is there a way to program the concept ruling out the implicit conversion from U to T const&?
Sure; lots of ways. One would be to pass the result to a function like template <class T, class U> void same_type(U const&) { BOOST_MPL_ASSERT((is_same<T,U>)); } You can see another similar example in the first example at http://www.boost.org/doc/libs/1_36_0/libs/concept_check/creating_concepts.ht... -- Dave Abrahams BoostPro Computing http://www.boostpro.com
participants (2)
-
Dave Abrahams
-
lcaminiti