Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2003-11-23 20:10:20


> Even if there aren't any other lessons, it seems clear we should be using
> the concept checking library more widely.
>
> From time-to-time other tales from the trenches might be aditional
> motivators, too.

Inspired by your post I decided to try out some concept checking on my
physical quantities class
using the boost concept checking techniques
The following is a genuine error message, though technically contrived
because I guess VC7.1 has optimised
the A variable... it doesnt always come out as clean !
I guess I should probably use a ConvertibleConcept but ... naming the
function for the error seems more fun !

The end result of this test for me is that concept checking is going to be a
major part of my physical_quantity library :-)

regards
Andy Little

-------------------------------------------------------------------------
#include "../pq_types/pq_length.hpp"
#include "../pq_types/pq_area.hpp"
#include "../class_template/operations/div.hpp"
using namespace physical_quantities;
int main()
{
    pq_length<>::m L1(10);
    pq_area<>::m2 A = L1 / (1/L1);
    pq_length<>::mm LL = L1 / (1/L1); //should - does fail d.a. here
}

------ Build started: Project: physical_quantities, Configuration: Debug
Win32 ------

Compiling...
main.cpp
c:\Projects\physical_quantities\class_template\generic.hpp(27) : error
C2440: 'initializing' : cannot convert from
'physical_quantities::pq_area<>::base' to
'physical_quantities::pq_length<>::base'
        No constructor could take the source type, or constructor overload
resolution was ambiguous
        c:\Projects\physical_quantities\class_template\generic.hpp(150) :
see reference to function template instantiation 'void
physical_quantities::InitialisationFailsDimensionalAnalysis<Abstract_pq,Abst
ract_pq1>(Abstract_pqA,Abstract_pqB)' being compiled
        with
        [
            Abstract_pq=physical_quantities::pq_length<>::base,
            Abstract_pq1=physical_quantities::pq_area<>::base,
            Abstract_pqA=physical_quantities::pq_length<>::base,
            Abstract_pqB=physical_quantities::pq_area<>::base
        ]
        c:\Projects\physical_quantities\test\main.cpp(9) : see reference to
function template instantiation
'physical_quantities::physical_quantity<Abstract_pq,Value_type,U_len,U_time,
U_mass,Q_mx>::physical_quantity<physical_quantities::pq_area<>::base,value_t
ype,0,0,0,null>(const
physical_quantities::physical_quantity<physical_quantities::pq_area<>::base,
Value_type,0,0,0,null> &)' being compiled
        with
        [
            Abstract_pq=physical_quantities::pq_length<>::base,
            Value_type=physical_quantities::pq_default_value_type,
            U_len=mm,
            U_time=0,
            U_mass=0,
            Q_mx=null,
            value_type=physical_quantities::pq_default_value_type
        ]

Build log was saved at "xxxxxxx\physical_quantities\Debug\BuildLog.htm"
physical_quantities - 1 error(s), 0 warning(s)

---------------------- Done ----------------------

    Build: 0 succeeded, 1 failed, 0 skipped


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