From 1165e5f511f9e45fb3babcd5f559df04480eadbf Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 16 Feb 2015 16:08:28 -0600 Subject: [PATCH] Provide specializations for ProductType. Add a test. --- include/deal.II/base/template_constraints.h | 6 ++ tests/base/product_type_05.cc | 66 +++++++++++++++++++++ tests/base/product_type_05.output | 4 ++ 3 files changed, 76 insertions(+) create mode 100644 tests/base/product_type_05.cc create mode 100644 tests/base/product_type_05.output diff --git a/include/deal.II/base/template_constraints.h b/include/deal.II/base/template_constraints.h index b2aa1fa9c3..b5b07894ed 100644 --- a/include/deal.II/base/template_constraints.h +++ b/include/deal.II/base/template_constraints.h @@ -360,6 +360,12 @@ struct ProductType #ifndef DEAL_II_WITH_CXX11 +template +struct ProductType +{ + typedef T type; +}; + template struct ProductType { diff --git a/tests/base/product_type_05.cc b/tests/base/product_type_05.cc new file mode 100644 index 0000000000..caeeb59561 --- /dev/null +++ b/tests/base/product_type_05.cc @@ -0,0 +1,66 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// test that ProductType can be resolved. same for +// ProductType,std::complex > + +#include "../tests.h" +#include +#include +#include +#include +#include +#include + +#include +#include + + + +template +void check() +{ + Assert (typeid(typename ProductType::type) == typeid(CompareType), + ExcInternalError()); + Assert (typeid(typename ProductType::type) == typeid(T() * U()), + ExcInternalError()); +} + + +int main() +{ + std::ofstream logfile("output"); + deallog.attach(logfile); + deallog.depth_console(0); + deallog.threshold_double(1.e-10); + + check(); + deallog << typename ProductType::type(2.345)*typename ProductType::type(3.456) + << ' ' + << typename ProductType::type(2.345*3.456) + << std::endl; + + check,std::complex,std::complex >(); + deallog << (typename ProductType,std::complex >::type(2.345, 1.23) * + typename ProductType,std::complex >::type(3.456, 2.45)) + << ' ' + << (typename ProductType,std::complex >::type + (std::complex(2.345, 1.23) * + std::complex(3.456, 2.45))) + << std::endl; + + deallog << "OK" << std::endl; +} diff --git a/tests/base/product_type_05.output b/tests/base/product_type_05.output new file mode 100644 index 0000000000..fe1bac9e55 --- /dev/null +++ b/tests/base/product_type_05.output @@ -0,0 +1,4 @@ + +DEAL::8.10432 8.10432 +DEAL::(5.09082,9.99613) (5.09082,9.99613) +DEAL::OK -- 2.39.5