Thomas Moulard <thomas.moulard(a)lrde.epita.fr> writes:
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog
from Thomas Moulard <thomas.moulard(a)lrde.epita.fr>
Add stc::exact.
* static/tests/exact.cc: test suite of stc::exact (new file).
* static/stc/exact.hh: implementation of stc::exact (new file).
* static/stc/any.hh: adding a typedef exact_t in stc::any.
* metalic/mlc/case.hh: fixing a bug in the protected defaults cases.
Nice work for a first patch!
However, there were some (small) mistakes; don't worry, this is normal
in the first contributions to a project. (You won't need to send a
correction, I've fixed them since).
First of all, the ChangeLog. All subprojects of Olena (Metalic,
Static, Extended, Olena, Dynamic) have their own ChangeLog. You
should write your changes in the one at the root of your
subproject. When you make changes across several subprojects (e.g.,
moving a file form mlc/ to xtd/), document your changes in the
top-level ChangeLog.
And don't forget to start your ChangeLog entries with a capital
letter, and to use imperative (``Add a typedef'', not ``adding a
typedef'').
Index: static/tests/exact.cc
--- static/tests/exact.cc (revision 0)
+++ static/tests/exact.cc (revision 0)
@@ -0,0 +1,161 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
+// Development Laboratory.
Take care when copying copyright headers; there are two recurring
mistakes:
- erroneous years;
- using the old address of the FSF (59 Temple Place) instead of their
current one (51 Franklin Street).
Here, you should have mentioned 2006 only, since you created this
file a few days ago.
+#include <iostream>
+#include <exact.hh> // FIXME: was stc/exact.hh
All header inclusions must be relative to the subproject root (in this
case, static/).
Tests are run through the `check' rule by make. When you add a test
case, don't forget to update the tests/Makefile.am of the
corresponding project.
Property changes on: static/tests/exact.cc
___________________________________________________________________
Name: svn:executable
+ *
Source file shall not be executable. :)
Index: static/stc/exact.hh
--- static/stc/exact.hh (revision 0)
+++ static/stc/exact.hh (revision 0)
@@ -0,0 +1,198 @@
+// Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 EPITA Research and
+// Development Laboratory.
Likewise for dates.
+# define stc_internal_is_any(T) \
+mlc::bexpr_< sizeof(internal::any_select(internal::makePtr< T >()))
+== sizeof(internal::yes_) >
If possible, avoid lines longer than 80 columns.
+
+
+
+namespace stc
+{
+
+ namespace internal
+ {
+ typedef char yes_;
+ struct no_ { char dummy[2]; };
+
+ template <typename E, typename P>
+ yes_ any_select(const stc::any<E,P>* arg);
+
+ no_ any_select(...);
+
+ template <typename T>
+ T* makePtr();
+
+ }
+
+ template <typename T>
+ struct is_any_
+ : public stc_internal_is_any(T)
+ {
+ };
+
+ template <typename T>
+ struct is_any_ < T* >;
+
+ template <typename T>
+ struct is_any_ < const T >;
+
+} // end of namespace stc
+
+
+mlc_case_equipment_for_namespace(stc);
+
+
+namespace stc
+{
+
+
+ namespace tag
+ {
+ struct exact;
+ }
+
+
+ template <class T>
+ struct case_<tag::exact, T, 1> : public mlc::where_ < stc::is_any_<T>
>
+ {
+ struct protected_
+ {
+ typedef typename T::exact_t ret;
+
+ static inline ret& impl(T& t)
This `inline' is probably superfluous: IIRC, methods whose definition
is given at the same time as their declaration (i.e., inside the class
definition) are automatically qualified inline.
Property changes on: static/stc/exact.hh
___________________________________________________________________
Name: svn:executable
+ *
Same as above.
Index: static/stc/any.hh
--- static/stc/any.hh (revision 485)
+++ static/stc/any.hh (working copy)
@@ -67,6 +67,8 @@
struct any <E,
dispatch_policy::best_speed>
{
+ typedef E exact_t;
exact_type is preferred to exact_t; the Olena coding style says:
``xxx_t looks too close from the std::*_t reserved types ''
(
http://www.lrde.epita.fr/cgi-bin/twiki/view/Olena/CodingStyle).
Thanks for your patch!