Boost logo

Boost :

From: Andy Little (andy_at_[hidden])
Date: 2004-01-25 20:07:47


"Daniel Frey" <d.frey_at_[hidden]> wrote in message
news:bv12qn$fs$1_at_sea.gmane.org...
> On Sun, 25 Jan 2004 01:11:17 +0100, Andy Little wrote:
>
> >> > pqs is not like YANL !
> >>
> >> Of course. This is why I tried to keep the constant library independent
> >> of a concrete unit library and provide a basic mechanism to support
> >> certain type-mappings that are needed for all unit libraries.
> >
> > Yep. If it can be done it will be good... but there are many ways it can
> > stall.
> > That is the only concern I have. We shall see...
>
> I uploaded the example to the files section, please have a look. As you
> will see, I had to modify your operator* in mul_scalar.hpp, of course the
> other operators need to be aware of the constant library as well. I think
> this is no problem when we agree that the constant library is a
> prerequisit of your unit library ;) Honestly, I think we have to think
> about this, as I am not yet sure whether we can find some general rules
> that everyone can follow to make arbitrary libraries compatible and
> independent of each other. Thoughts?

Tried in VC7.1:

?

regards
Andy Little

source
-----------------------------
#include "../pqs.hpp"
using namespace physical_quantities;

#include "ideal_gas_law_constant.hpp"
#include "gas_constant.hpp"

template< typename Y >
typename pq_substance< Y >::mol
idealGasLaw( const typename pq_pressure< Y >::Pa& p,
             const typename pq_volume< Y >::m3& v,
             const typename pq_temperature< Y >::K& t )
{
    using physical_quantities::constants::chemistry::R;
    return p * v / ( R * t );
}

int main()
{
    typedef double X;

    pq_pressure< X >::Pa P(1.01325e5);
    pq_length< X >::m r(0.5e-6);
    pq_volume< X >::m3 V = 4./3. * 3.141592 * power<3>(r);
    pq_temperature< X >::K T(310);
//succeeds
    pq_substance<X>::mol subst1 = P * V /(physics::ideal_gas_constant<>::R
* T);
//fails (line 28)
    pq_substance< X >::mol subst = idealGasLaw< double >( P, V, T );

    std::cout << subst1 << std::endl;
}

VC7.1 out:
----------------
------ Build started: Project: physical_quantities, Configuration: Debug
Win32 ------

Compiling...
ideal_gas_law_constant.cpp
physical_quantities\examples\constant\operators.hpp(168) : error C2064: term
does not evaluate to a function taking 0 arguments
        physical_quantities\examples\ideal_gas_law_constant.cpp(14) : see
reference to function template instantiation 'boost::disable_if_c<B,T>::type
boost::operator
*<physical_quantities::constants::chemistry::R_value,physical_quantities::pq
_temperature<Value_type>::K>(boost::constant<F>,const T &)' being compiled
        with
        [
            B=false,

T=physical_quantities::pq_temperature<physical_quantities::pq_default_value_
type>::K,
            Value_type=physical_quantities::pq_default_value_type,
            F=physical_quantities::constants::chemistry::R_value
        ]
     physical_quantities\examples\ideal_gas_law_constant.cpp(28) : see
reference to function template instantiation
'physical_quantities::pq_substance<Value_type>::mol
idealGasLaw<double>(const physical_quantities::pq_pressure<Value_type>::Pa
&,const physical_quantities::pq_volume<Value_type>::m3 &,const
physical_quantities::pq_temperature<Value_type>::K &)' being compiled
        with
        [
            Value_type=physical_quantities::pq_default_value_type
        ]

Build log was saved at ""
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