Boost logo

Boost :

Subject: Re: [boost] [concept_check] addable
From: Dave Abrahams (dave_at_[hidden])
Date: 2012-04-19 19:33:06


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-tp4572138p4572138.html
> 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

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk