BUG: missing constructor for pTraits specializations

This commit is contained in:
Mark Olesen
2010-06-15 18:23:49 +02:00
parent 0a4c8f7266
commit aa4781fcc0
10 changed files with 81 additions and 7 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -27,15 +27,49 @@ Description
#include "IOstreams.H"
#include "pTraits.H"
#include "vector.H"
#include "tensor.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
template<class T>
void printTraits()
{
Info<< pTraits<T>::typeName
<< ": zero=" << pTraits<T>::zero
<< " one=" << pTraits<T>::one << endl;
}
template<class T>
void printTraits(const pTraits<T>& p)
{
Info<< p.typeName << " == " << p << endl;
}
int main()
{
Info<< pTraits<scalar>::typeName << endl;
printTraits<bool>();
printTraits<label>();
printTraits<scalar>();
printTraits<vector>();
printTraits<tensor>();
{
pTraits<bool> b(true);
printTraits(b);
}
{
pTraits<label> l(100);
printTraits(l);
}
printTraits(pTraits<scalar>(3.14159));
Info<< "End\n" << endl;

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -38,6 +38,12 @@ const Scalar pTraits<Scalar>::max = ScalarVGREAT;
const char* pTraits<Scalar>::componentNames[] = { "x" };
pTraits<Scalar>::pTraits(const Scalar& p)
:
p_(p)
{}
pTraits<Scalar>::pTraits(Istream& is)
{
is >> p_;

View File

@ -65,6 +65,9 @@ public:
// Constructors
//- Construct from primitive
explicit pTraits(const Scalar&);
//- Construct from Istream
pTraits(Istream&);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -28,11 +28,17 @@ License
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const char* const Foam::pTraits<bool>::typeName = "bool";
const bool Foam::pTraits<bool>::zero(false);
const bool Foam::pTraits<bool>::one(true);
const bool Foam::pTraits<bool>::zero = false;
const bool Foam::pTraits<bool>::one = true;
const char* Foam::pTraits<bool>::componentNames[] = { "x" };
Foam::pTraits<bool>::pTraits(const bool& p)
:
p_(p)
{}
Foam::pTraits<bool>::pTraits(Istream& is)
{
is >> p_;

View File

@ -91,6 +91,9 @@ public:
// Constructors
//- Construct from primitive
explicit pTraits(const bool&);
//- Construct from Istream
pTraits(Istream&);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -41,6 +41,12 @@ const label pTraits<label>::max = labelMax;
const char* pTraits<label>::componentNames[] = { "x" };
pTraits<label>::pTraits(const label& p)
:
p_(p)
{}
pTraits<label>::pTraits(Istream& is)
{
is >> p_;

View File

@ -165,6 +165,9 @@ public:
// Constructors
//- Construct from primitive
explicit pTraits(const label&);
//- Construct from Istream
pTraits(Istream&);

View File

@ -41,6 +41,12 @@ const uLabel pTraits<uLabel>::max = uLabelMax;
const char* pTraits<uLabel>::componentNames[] = { "x" };
pTraits<uLabel>::pTraits(const uLabel& p)
:
p_(p)
{}
pTraits<uLabel>::pTraits(Istream& is)
{
is >> p_;

View File

@ -149,6 +149,9 @@ public:
// Constructors
//- Construct from primitive
explicit pTraits(const uLabel&);
//- Construct from Istream
pTraits(Istream&);

View File

@ -55,11 +55,13 @@ public:
// Constructors
//- Construct from primitive
pTraits(const PrimitiveType& p)
:
PrimitiveType(p)
{}
//- Construct from Istream
pTraits(Istream& is)
:
PrimitiveType(is)
@ -68,11 +70,13 @@ public:
// Member operators
//- Access to the primitive
operator PrimitiveType() const
{
return *this;
}
//- Access to the primitive
operator PrimitiveType&()
{
return *this;