<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">Hi,<br>
<br>
on the developer meeting in Aachen we decided to introduce a new
namespace Dune::std for STL like containers and the tuples stuff.
Didn't we plan to introduce a subdirectory for the respective
headers as well? If yes, I'd suggest to place the C++11 headers in
that same directory. Having two folders, say 'dune/common/std/'
and 'dune/common/c++11', would leave me unsure about where to find
e. g. the headers shared_ptr.hh or tuples.hh. How about a
subdirectory 'dune/common/std/c++11/' instead?<br>
<br>
Best,<br>
<br>
Christoph<br>
<br>
On 10/01/2013 10:45 AM, Oliver Sander wrote:<br>
</div>
<blockquote cite="mid:524A8BB8.4050100@igpm.rwth-aachen.de"
type="cite">
<pre wrap="">Am 01.10.2013 10:26, schrieb Christian Engwer:
</pre>
<blockquote type="cite">
<pre wrap="">On Tue, Oct 01, 2013 at 10:20:20AM +0200, Martin Nolte wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi Oli,
I don't have a strong opinion on this. Feel free to rename the file
to constexpr.hh.
However, my idea was to avoid cluttering dune-common with lots of
header files for c++11 compatiblity (we already have nullptr.hh,
staticassert.hh, ...). Therefore, I added 1 single header file that
should contain all those macros and other fallback stuff. It's just
a suggestion (the corresponding eMail was intended to follow later
today).
</pre>
</blockquote>
<pre wrap="">
How about a subdirectory c++11 ?
</pre>
</blockquote>
<pre wrap="">I wouldn't mind that.
--
Oliver
</pre>
<blockquote type="cite">
<pre wrap="">Christian
</pre>
<blockquote type="cite">
<pre wrap="">Best,
Martin
On 10/01/2013 10:00 AM, Oliver Sander wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi Martin,
is cxx11.hh a good name for the file containing the constexpr wrapper?
>From the name alone I'd be hard-pressed to guess what it contains.
Can we change the name to constexpr.hh? That would be more consistent
with unused.hh and deprecated.hh.
Best,
Oliver
Am 01.10.2013 08:40, schrieb Martin Nolte:
</pre>
<blockquote type="cite">
<pre wrap="">New commit, appeared at Tue Oct 1 08:40:50 2013 +0200
as part of the following ref changes:
branch refs/heads/master updated from b6e7446 -> 45990b6
Browsable version: <a class="moz-txt-link-freetext" href="http://cgit.dune-project.org/repositories/dune-common/commit/?id=45990b699256890185c365419ef75c5c88c33f12">http://cgit.dune-project.org/repositories/dune-common/commit/?id=45990b699256890185c365419ef75c5c88c33f12</a>
======================================================================
commit 45990b699256890185c365419ef75c5c88c33f12
Author: Martin Nolte <a class="moz-txt-link-rfc2396E" href="mailto:nolte@mathematik.uni-freiburg.de"><nolte@mathematik.uni-freiburg.de></a>
Date: Tue Oct 1 08:37:28 2013 +0200
[c++11] add support for C++11 constexpr
As decided on the developer meeting in Aachen, we support (but do not
rely on) the C++11 keyword constexpr. This patch adds an m4-check for
constexpr and a header (cxx11.hh) defining a macro DUNE_CONSTEXPR either
as constexpr or empty (depending on the compiler support for it). It is
then used in FieldVector and FieldMatrix on size, rows, and cols.
dune/common/CMakeLists.txt | 1 +
dune/common/Makefile.am | 1 +
dune/common/cxx11.hh | 10 ++++++++++
dune/common/fmatrix.hh | 9 +++++----
dune/common/fvector.hh | 10 ++++++++--
m4/cxx11_constexpr.m4 | 28 ++++++++++++++++++++++++++++
m4/dune_common.m4 | 1 +
7 files changed, 54 insertions(+), 6 deletions(-)
create mode 100644 dune/common/cxx11.hh
create mode 100644 m4/cxx11_constexpr.m4
diff --git a/dune/common/CMakeLists.txt b/dune/common/CMakeLists.txt
index 43fe8fc..f1dc93b 100644
--- a/dune/common/CMakeLists.txt
+++ b/dune/common/CMakeLists.txt
@@ -31,6 +31,7 @@ install(FILES
bitsetvector.hh
classname.hh
collectivecommunication.hh
+ cxx11.hh
debugallocator.hh
debugstream.hh
deprecated.hh
diff --git a/dune/common/Makefile.am b/dune/common/Makefile.am
index 75e9d54..9a645f6 100644
--- a/dune/common/Makefile.am
+++ b/dune/common/Makefile.am
@@ -28,6 +28,7 @@ commoninclude_HEADERS = \
bitsetvector.hh \
classname.hh \
collectivecommunication.hh \
+ cxx11.hh \
debugallocator.hh \
debugstream.hh \
deprecated.hh \
diff --git a/dune/common/cxx11.hh b/dune/common/cxx11.hh
new file mode 100644
index 0000000..8ba3101
--- /dev/null
+++ b/dune/common/cxx11.hh
@@ -0,0 +1,10 @@
+#ifndef DUNE_COMMON_CXX11_HH
+#define DUNE_COMMON_CXX11_HH
+
+#if HAVE_CONSTEXPR
+#define DUNE_CONSTEXPR constexpr
+#else // #if HAVE_CONSTEXPR
+#define DUNE_CONSTEXPR
+#endif // #else // #if HAVE_CONSTEXPR
+
+#endif // #ifndef DUNE_COMMON_CXX11_HH
diff --git a/dune/common/fmatrix.hh b/dune/common/fmatrix.hh
index 826399e..adfdf61 100644
--- a/dune/common/fmatrix.hh
+++ b/dune/common/fmatrix.hh
@@ -8,6 +8,7 @@
#include <cstddef>
#include <iostream>
+#include <dune/common/cxx11.hh>
#include <dune/common/exceptions.hh>
#include <dune/common/fvector.hh>
#include <dune/common/densematrix.hh>
@@ -168,8 +169,8 @@ namespace Dune
}
// make this thing a matrix
- size_type mat_rows() const { return ROWS; }
- size_type mat_cols() const { return COLS; }
+ DUNE_CONSTEXPR size_type mat_rows() const { return ROWS; }
+ DUNE_CONSTEXPR size_type mat_cols() const { return COLS; }
row_reference mat_access ( size_type i )
{
@@ -270,8 +271,8 @@ namespace Dune
}
// make this thing a matrix
- size_type mat_rows() const { return 1; }
- size_type mat_cols() const { return 1; }
+ DUNE_CONSTEXPR size_type mat_rows() const { return 1; }
+ DUNE_CONSTEXPR size_type mat_cols() const { return 1; }
row_reference mat_access ( size_type i )
{
diff --git a/dune/common/fvector.hh b/dune/common/fvector.hh
index 6084355..4d113c8 100644
--- a/dune/common/fvector.hh
+++ b/dune/common/fvector.hh
@@ -11,6 +11,8 @@
#include <cstring>
#include <utility>
+#include <dune/common/cxx11.hh>
+
#include "typetraits.hh"
#include "exceptions.hh"
#include "array.hh"
@@ -156,8 +158,10 @@ namespace Dune {
}
using Base::operator=;
+ DUNE_CONSTEXPR size_type size () const { return vec_size(); }
+
// make this thing a vector
- size_type vec_size() const { return SIZE; }
+ DUNE_CONSTEXPR size_type vec_size () const { return SIZE; }
K & vec_access(size_type i) { return _data[i]; }
const K & vec_access(size_type i) const { return _data[i]; }
private:
@@ -243,8 +247,10 @@ namespace Dune {
return *this;
}
+ DUNE_CONSTEXPR size_type size () const { return vec_size(); }
+
//===== forward methods to container
- size_type vec_size() const { return 1; }
+ DUNE_CONSTEXPR size_type vec_size () const { return 1; }
K & vec_access(size_type i)
{
assert(i == 0);
diff --git a/m4/cxx11_constexpr.m4 b/m4/cxx11_constexpr.m4
new file mode 100644
index 0000000..12b7b7a
--- /dev/null
+++ b/m4/cxx11_constexpr.m4
@@ -0,0 +1,28 @@
+# tests for C++11 constexpr support
+# the associated macro is called HAVE_CONSTEXPR
+
+AC_DEFUN([CXX11_CONSTEXPR_CHECK],[
+ AC_CACHE_CHECK([for C++11 constexpr], dune_cv_cxx11_constexpr_support, [
+ AC_REQUIRE([AC_PROG_CXX])
+ AC_REQUIRE([GXX0X])
+ AC_LANG_PUSH([C++])
+ AC_COMPILE_IFELSE([
+ AC_LANG_PROGRAM([
+ constexpr int foo () { return 0; }
+
+ template< int v >
+ struct A
+ {
+ static const int value = v;
+ };
+ ],[
+ return A< foo() >::value;
+ ])],
+ dune_cv_cxx11_constexpr_support=yes,
+ dune_cv_cxx11_constexpr_support=no)
+ AC_LANG_POP
+ ])
+ if test "x$dune_cv_cxx11_constexpr_support" = xyes; then
+ AC_DEFINE(HAVE_CONSTEXPR, 1, [Define to 1 if C++11 constexpr is supported])
+ fi
+])
diff --git a/m4/dune_common.m4 b/m4/dune_common.m4
index d9debce..5b13851 100644
--- a/m4/dune_common.m4
+++ b/m4/dune_common.m4
@@ -26,6 +26,7 @@ AC_DEFUN([DUNE_COMMON_CHECKS],
AC_REQUIRE([RVALUE_REFERENCES_CHECK])
AC_REQUIRE([INITIALIZER_LIST_CHECK])
AC_REQUIRE([CXX11_CONDITIONAL_CHECK])
+ AC_REQUIRE([CXX11_CONSTEXPR_CHECK])
AC_REQUIRE([DUNE_BOOST_BASE])
AC_REQUIRE([MAKE_SHARED])
AC_REQUIRE([DUNE_LINKCXX])
_______________________________________________
Dune-Commit mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune-Commit@dune-project.org">Dune-Commit@dune-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dune-project.org/mailman/listinfo/dune-commit">http://lists.dune-project.org/mailman/listinfo/dune-commit</a>
</pre>
</blockquote>
<pre wrap="">
_______________________________________________
Dune-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune-devel@dune-project.org">Dune-devel@dune-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dune-project.org/mailman/listinfo/dune-devel">http://lists.dune-project.org/mailman/listinfo/dune-devel</a>
</pre>
</blockquote>
<pre wrap="">
--
Dr. Martin Nolte <a class="moz-txt-link-rfc2396E" href="mailto:nolte@mathematik.uni-freiburg.de"><nolte@mathematik.uni-freiburg.de></a>
Universität Freiburg phone: +49-761-203-5630
Abteilung für angewandte Mathematik fax: +49-761-203-5632
Hermann-Herder-Straße 10
79104 Freiburg, Germany
_______________________________________________
Dune-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune-devel@dune-project.org">Dune-devel@dune-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dune-project.org/mailman/listinfo/dune-devel">http://lists.dune-project.org/mailman/listinfo/dune-devel</a>
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<pre wrap="">
</pre>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
Dune-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Dune-devel@dune-project.org">Dune-devel@dune-project.org</a>
<a class="moz-txt-link-freetext" href="http://lists.dune-project.org/mailman/listinfo/dune-devel">http://lists.dune-project.org/mailman/listinfo/dune-devel</a>
</pre>
</blockquote>
<br>
<br>
<div class="moz-signature">-- <br>
<title></title>
<font color="#666666"><small>Christoph Gersbacher</small><small>
<a
href="mailto:christoph.gersbacher@mathematik.uni-freiburg.de"><font
color="#3333ff"><christoph.gersbacher@mathematik.uni-freiburg.de></font></a></small><br>
</font>
<div class="moz-signature">
<div class="moz-signature"><font color="#666666"><small>Abteilung
für
Angewandte Mathematik
</small><br>
</font><font color="#666666"><small>Albert-Ludwigs-Universität
Freiburg
</small><br>
</font><font color="#666666"><small>Hermann-Herder-Str. 10
</small><br>
</font><font color="#666666"><small>D-79104 Freiburg im
Breisgau
</small><br>
</font><font color="#666666"><small>Tel.: +49 (0)761 / 203
5645
</small><br>
</font><font color="#666666"><small>Fax: +49 (0)761 / 203 5632</small></font>
</div>
</div>
</div>
</body>
</html>