
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.