<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to tickets</title><link>https://sourceforge.net/p/contractpp/tickets/</link><description>Recent changes to tickets</description><atom:link href="https://sourceforge.net/p/contractpp/tickets/feed.rss" rel="self"/><language>en</language><lastBuildDate>Fri, 01 Mar 2013 19:08:56 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/contractpp/tickets/feed.rss" rel="self" type="application/rss+xml"/><item><title>Fix all copyright and licensing info</title><link>https://sourceforge.net/p/contractpp/tickets/104/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Proper year ...-2013, remove sourceforce website and use boost website instead, etc&lt;br /&gt;
&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Fri, 01 Mar 2013 19:08:56 -0000</pubDate><guid>https://sourceforge.net4c3817191576083e028c8551355374f447f584ca</guid></item><item><title>Do not provide separate public header files unless their inclusion is exlusive</title><link>https://sourceforge.net/p/contractpp/tickets/103/</link><description/><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Fri, 01 Mar 2013 19:08:02 -0000</pubDate><guid>https://sourceforge.net7d7cf2bc7581c5eba780396462bc0cdb4d2605ad</guid></item><item><title>check behavior when linking lib with contract disabled</title><link>https://sourceforge.net/p/contractpp/tickets/102/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;I wanted to ask you about the behavior of Contract++ in the following scenario. I was trying to determine what happens if I link a program compiled with all contract checks disabled against the library compiled with all checks enabled. The code I tried is something like below:&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;file include.h:&lt;br /&gt;
CONTRACT_FUNCTION(&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;int (diff) ( (int) i, (int) j )&lt;br /&gt;
precondition(lessEqual(i, j))&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;);&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;file main.cpp:&lt;br /&gt;
&lt;/p&gt;
&lt;h1 id="define-contract_config_no_preconditions-1"&gt;define CONTRACT_CONFIG_NO_PRECONDITIONS 1&lt;/h1&gt;
&lt;h1 id="include-wzxhzdk0contracthppwzxhzdk1"&gt;include &amp;lt;contract.hpp&amp;gt;&lt;/h1&gt;
&lt;h1 id="include-includeh"&gt;include "include.h"&lt;/h1&gt;
&lt;p&gt;int main()&lt;br /&gt;
{&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;auto i = diff(7, 5);&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;}&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;file second.cpp:&lt;br /&gt;
&lt;/p&gt;
&lt;h1 id="include-wzxhzdk2contracthppwzxhzdk3"&gt;include &amp;lt;contract.hpp&amp;gt;&lt;/h1&gt;
&lt;h1 id="include-includeh_1"&gt;include "include.h"&lt;/h1&gt;
&lt;p&gt;int CONTRACT_FREE_BODY(diff) (int i, int j)&lt;br /&gt;
{&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;return j - i;&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;}&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;I found that when I call my function diff() inside main(), the precondition is not checked -- expression not even evaluated -- even though it is compiled with precondition checks enabled. This is a very nice behavior, and a significant improvement over using asserts, because I do not have to recompile the library, when I want to disable the checks. I am just surprised that I didn't find it in the documentation. &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Is this an intended feature? N1962 Describes a possible implementation of concept checks that adds no run-time overhead when contract disabled, not requiring at the same time the recompilation of the library. Is it also the case for your library? I know the preconditions are not evaluated in such "mixed configuration" but I cannot determine if some overhead connected to the function call is present. &lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;If this is intended behavior, this feature is remarkable and deserves a honored place in the documentation. The docs do mention disabling the checks, but do not explicitly describe the "mixed mode". I thought that the library worked like normal assert's (If you change the setting you have to recompile the library). Or did I miss it in the docs? &lt;br /&gt;
&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Mon, 21 Jan 2013 18:56:23 -0000</pubDate><guid>https://sourceforge.netd68ba2f073f5ffa700ae30380b69ae215ad90484</guid></item><item><title>use "static if" syntax for assertion requirements</title><link>https://sourceforge.net/p/contractpp/tickets/101/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Following N3329 "static if" proposal, replace assertion requirement syntax:&lt;br /&gt;
&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="nb"&gt;postcondition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nb"&gt;back&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;value&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;requires&lt;/span&gt; &lt;span class="nx"&gt;boost&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nl"&gt;has_eqaul&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nl"&gt;value&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;with a static if:&lt;br /&gt;
&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span class="nb"&gt;postcondition&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="nx"&gt;static&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;boost&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nl"&gt;has_equal&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nb"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nl"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="nb"&gt;back&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nb"&gt;value&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="c1"&gt;// optional else ( ... )&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Tue, 02 Oct 2012 21:41:10 -0000</pubDate><guid>https://sourceforge.net5761804ad0f0788375470a950f4204dc1c58fff4</guid></item><item><title>document concurrency in contracts</title><link>https://sourceforge.net/p/contractpp/tickets/100/</link><description>&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;The docs say that in order to make disabling of nested assertions&lt;br /&gt;
thread-safe in multi-threaded programs, the library needs to use a global&lt;br /&gt;
lock. Sorry if I am talking nonsense now (I have no intuition of using DbC&lt;br /&gt;
in multi-threaded apps), but is it not possible to use thread_local storage&lt;br /&gt;
for this purpose? Is it possible that executing an assertion in one thread&lt;br /&gt;
would cause the execution of another (nested) assertion in another thread?&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I'll think about it. Generally speaking, multi-threading needs to be&lt;br /&gt;
handled a level higher than contracts... &lt;span&gt;[Meyer97]&lt;/span&gt; also explains how&lt;br /&gt;
concurrent programming might fail the contracts (and then he&lt;br /&gt;
introduces SCOOP as a solution but Eiffel didn't implement SCOOP until&lt;br /&gt;
later). I can provide more information on "contracts and concurrency"&lt;br /&gt;
(maybe in a separated email thread) if needed.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Add a small section somewhere explaining the issues with contracts and concurrency (see &lt;span&gt;[Meyer97]&lt;/span&gt;).&lt;br /&gt;
&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Mon, 10 Sep 2012 19:01:42 -0000</pubDate><guid>https://sourceforge.net172bacbd07e61919c91e384b64aa2a12979f1234</guid></item><item><title>clarify why contracts are allowed for private and protected members</title><link>https://sourceforge.net/p/contractpp/tickets/99/</link><description>&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;The documentation says that you can use protected and private members in&lt;br /&gt;
contracts because "C++ provides programmers ways around access level&lt;br /&gt;
restrictions (e.g., friend and function pointers)". Next, we read that&lt;br /&gt;
"only public member functions shall check class invariants. Private and&lt;br /&gt;
protected member functions are allowed to brake class invariants because&lt;br /&gt;
private and protected member are part of the class implementation and not&lt;br /&gt;
of its specification".&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This 2nd statement is correct. The 1st statement means that in C++ you&lt;br /&gt;
can never prevent people from programming junk like this which will&lt;br /&gt;
break the public interface (the same can be done without static):&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;h1 id="include-wzxhzdk0iostreamwzxhzdk1"&gt;include &amp;lt;iostream&amp;gt;&lt;/h1&gt;
&lt;p&gt;class x&lt;br /&gt;
{&lt;br /&gt;
public: static void pub ( void ) { std::cout &amp;lt;&amp;lt; "pub" &amp;lt;&amp;lt; std::endl; }&lt;br /&gt;
private: static void priv ( void ) { std::cout &amp;lt;&amp;lt; "priv" &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
}&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;typedef void (*fptr) ( void );&lt;br /&gt;
public: static fptr bad ( void ) { return priv; }&lt;br /&gt;
};&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;int main ( void )&lt;br /&gt;
{&lt;br /&gt;
x::pub();&lt;br /&gt;
void (*priv) ( void ) = x::bad();&lt;br /&gt;
priv(); // calls a private function :(&lt;br /&gt;
return 0;&lt;br /&gt;
};&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;The call to priv via the function pointer is done outside the class&lt;br /&gt;
implementation but it won't check the invariants--but if you program&lt;br /&gt;
"bad" then you're on your own! That's all I wanted to say with the 1st&lt;br /&gt;
statement (which is actually an observation from The C++ Programming&lt;br /&gt;
Language, Stroustrup). I can clarify this in the docs.&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;I feel I have been misunderstood. Let me clarify. I understand how one can&lt;br /&gt;
overcame the member access restrictions in C++ with hacks. I do not think&lt;br /&gt;
you need to clarify it in the docs. The way I understand the docs is that&lt;br /&gt;
you use these hacks as rationale for allowing private and protected members&lt;br /&gt;
in contracts.&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;No. Private and protected members are allowed in contracts because&lt;br /&gt;
they can have pre and post even if they never check inv. Public&lt;br /&gt;
members are allowed in contract because they have pre, post, and also&lt;br /&gt;
check inv.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;On a separate note, you cal always call a private or protected member&lt;br /&gt;
from a public scope using the access hacks. If you do so beware that&lt;br /&gt;
inv will not be checked (as they shouldn't because you are calling a&lt;br /&gt;
private or protected member) even if the call is made from a public&lt;br /&gt;
scope--you're on your own.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;That's what I tried to say in the docs. I'll clarify the docs.&lt;br /&gt;
&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Mon, 10 Sep 2012 18:59:24 -0000</pubDate><guid>https://sourceforge.netd876d8553d3d7456e06bbaf983c850a1a984267d</guid></item><item><title>note that variadic macros are not part of C++03 up-front</title><link>https://sourceforge.net/p/contractpp/tickets/98/</link><description>&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;p&gt;In the documentation (Introduction) we read that "This library is&lt;br /&gt;
implemented for the C++03 &amp;lt;&lt;a href="http://en.wikipedia.org/wiki/C%2B%2B" rel="nofollow"&gt;http://en.wikipedia.org/wiki/C%2B%2B&lt;/a&gt;&amp;gt; standard&lt;br /&gt;
and it does not require C++11 &amp;lt;&lt;a href="http://en.wikipedia.org/wiki/C%2B%2B11" rel="nofollow"&gt;http://en.wikipedia.org/wiki/C%2B%2B11&lt;/a&gt;&amp;gt;." I&lt;br /&gt;
think it is a bit imprecise, because many examples in the docs silently&lt;br /&gt;
assume that variadic macros, which are not part of C++03, are available. I&lt;br /&gt;
believe something like this would be more accurate "This library is&lt;br /&gt;
designed to work on C++03 compilers that support variadic macros; no other&lt;br /&gt;
C++11 support is necessary. Additionally, if variadic macros are not&lt;br /&gt;
supported, this library works in &amp;gt;&amp;gt;strict C++03&amp;lt;&amp;lt; mode with slightly&lt;br /&gt;
different syntax."&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This is more correct but it's too verbose for the Introduction&lt;br /&gt;
section. Also variadic macros were part of C99, etc before C++11. I&lt;br /&gt;
might add a footnote to the statement that say "technically variadic&lt;br /&gt;
macros are not part of C++03, if your compiler doesn't support&lt;br /&gt;
variadic macros see No Variadic Macros section".&lt;br /&gt;
&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Mon, 10 Sep 2012 18:57:43 -0000</pubDate><guid>https://sourceforge.netc87e34075a5be06a6ae73dc01ef46ed59c706c92</guid></item><item><title>add a note that lib used to support non-macro API</title><link>https://sourceforge.net/p/contractpp/tickets/97/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Add a note that lib used to support non-macro API which was later abandoned (just mentioning this in the Release Notes section makes it too hidden).&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Also let's keep in mind that contracts should be specified at the&lt;br /&gt;
declaration site. In any case, this is the best I was able to do&lt;br /&gt;
without using macros (rev 0.3.490 of the lib that still supported the&lt;br /&gt;
non-macro API):&lt;br /&gt;
&lt;a href="http://contractpp.svn.sourceforge.net/viewvc/contractpp/releases/contractpp_0_3_490/doc/html/contract__/without_the_macros.html"&gt;http://contractpp.svn.sourceforge.net/viewvc/contractpp/releases/contractpp_0_3_490/doc/html/contract__/without_the_macros.html&lt;/a&gt;&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Essentially this used function pointers (I guess you could similarly&lt;br /&gt;
use functors) to pass to the lib the functions that checked&lt;br /&gt;
pre/post/etc so the lib could check. This was abandoned because of the&lt;br /&gt;
large amount of boiler-plate code that users have to program,&lt;br /&gt;
including repeating the function signature a few times to program the&lt;br /&gt;
pre/post/body/etc functions to pass to the lib. Also subcontracting&lt;br /&gt;
relied on the user repeating bases classes everywhere making the code&lt;br /&gt;
very hard to maintain. Finally, disabling the contract code on&lt;br /&gt;
compilation (i.e. removing the pre/post/body/etc functions/functors)&lt;br /&gt;
required the user to manually program #ifdef and the all thing got&lt;br /&gt;
pretty ugly.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;I don't see how C++11 could improve this (also lambdas can't be used in declarations which is were contracts belong).&lt;br /&gt;
&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Mon, 10 Sep 2012 18:51:29 -0000</pubDate><guid>https://sourceforge.net6eeceb2e171e32514edf597b8f21382aa0d61e0c</guid></item><item><title>move static-assertions and ConceptCheck into a check clausule</title><link>https://sourceforge.net/p/contractpp/tickets/96/</link><description>&lt;div class="markdown_content"&gt;&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;ul&gt;
&lt;li&gt;Removal of the Concepts part.&lt;br /&gt;
The use of Boost.ConceptCheck to emulate C++ concepts proposal is in my&lt;br /&gt;
opinion erroneous. Boost.Concept.Check is used to assert the actual&lt;br /&gt;
parameter satisfy statically the concept conditions, while if I'm not&lt;br /&gt;
wrong&lt;br /&gt;
the C++ Concepts proposal use the requires clause to state the&lt;br /&gt;
conditions&lt;br /&gt;
of&lt;br /&gt;
a possible instantiations. Using the same grammar with different&lt;br /&gt;
semantics&lt;br /&gt;
is confusing. In a last resort, if this feature is preserved, the&lt;br /&gt;
requires&lt;br /&gt;
keyword must be changed by another one.&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;If that were to be the final decision, I'll remove the interface to&lt;br /&gt;
Boost.ConceptCheck or I can use any (alphanumeric) mane rather than&lt;br /&gt;
requires (e.g., where).&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;p&gt;However, I can use the requires clausule to do multiple things:&lt;br /&gt;
1. Check concepts defined using Boost.ConceptCheck (current, I'd leave&lt;br /&gt;
it as is).&lt;br /&gt;
2. Check static_assert (under consideration, to be moved here from&lt;br /&gt;
within pre/post/inv).&lt;br /&gt;
3. Check Boost.Generic-like concepts implemented using C++11&lt;br /&gt;
expression SFINAE (for future... this will be &lt;em&gt;a lot&lt;/em&gt; of work...).&lt;br /&gt;
I should be able to support of all those because I can distinguish 2&lt;br /&gt;
using the pp (starts with static_assert)&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;I will really prefer the static_assert goes outside requires, e.g. in a&lt;br /&gt;
new&lt;br /&gt;
&lt;em&gt;check&lt;/em&gt; clause. This clause could also contain the ConceptCheck part. In&lt;br /&gt;
this way it is clear that the requires part will disable the&lt;br /&gt;
instantiation&lt;br /&gt;
if not satisfied, and the check part will report a compile-time error if&lt;br /&gt;
not&lt;br /&gt;
satisfied.&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;and I can distinguish between&lt;br /&gt;
1 and 2 using the compiler for example using a (hidden) tagging base&lt;br /&gt;
class to all concepts defined for 3.&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;I'm not sure this distinction is possible. For function templates, the&lt;br /&gt;
requires part associated to ConceptCheck should be included in the&lt;br /&gt;
function&lt;br /&gt;
definition, while the one associated to enable_if/SFINAE c++ proposal&lt;br /&gt;
concepts emulation should be part of the C++ declaration. For template&lt;br /&gt;
classes, ConceptCheck goes to the members part, while Concepts goes to&lt;br /&gt;
the&lt;br /&gt;
template parameter part.&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;p&gt;As you can see the semantics are different, so a specific keyword would&lt;br /&gt;
help&lt;br /&gt;
to identify the difference.&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;Can you provide an example of how all of this would ideally look like?&lt;br /&gt;
You can also pick a "keyword" other than requires that makes sense to&lt;br /&gt;
you and then indicate where to use requires and where to use the other&lt;br /&gt;
keyword in the example. Maybe you start from the static_assert example&lt;br /&gt;
I gave:&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;p&gt;template&amp;lt; typename To, typename From &amp;gt;&lt;br /&gt;
requires // new concepts??&lt;br /&gt;
Convertible&amp;lt;From, To&amp;gt; // disable this declaration using&lt;br /&gt;
SFINAE??&lt;br /&gt;
unless // static_assert and Boost.ConceptCheck??&lt;br /&gt;
static_assert(sizeof(To) &amp;gt;= sizeof(From), "destination too&lt;br /&gt;
small"), // generate compiler-error??&lt;br /&gt;
boost::Copyable&amp;lt;From&amp;gt; // generate compiler-error??&lt;br /&gt;
To&lt;em&gt; memcopy ( To&lt;/em&gt; to, From* from )&lt;br /&gt;
precondition {&lt;br /&gt;
to; // pointer not null&lt;br /&gt;
from; // pointer not null&lt;br /&gt;
}&lt;br /&gt;
{&lt;br /&gt;
// ...&lt;br /&gt;
}&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;&lt;/blockquote&gt;
&lt;blockquote&gt;
&lt;p&gt;I will use &lt;em&gt;check&lt;/em&gt; as keyword for the static_assert and ConceptCheck part&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;template&amp;lt; typename To, typename From &amp;gt;&lt;br /&gt;
requires // used with enable_if in the declaration part&lt;br /&gt;
is_convertible&amp;lt;From, To&amp;gt;::value&lt;br /&gt;
check // included in the function body&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;assert(sizeof(To) &amp;gt;= sizeof(From), "destination too small")&lt;br /&gt;
&amp;amp;&amp;amp; boost::Copyable&amp;lt;From&amp;gt;&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;To&lt;em&gt; memcopy ( To&lt;/em&gt; to, From* from )&lt;br /&gt;
precondition {&lt;br /&gt;
to; // pointer not null&lt;br /&gt;
from; // pointer not null&lt;br /&gt;
}&lt;br /&gt;
{&lt;br /&gt;
// ...&lt;br /&gt;
}&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;You could also use the check&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;sizeof(To) &amp;gt;= sizeof(From)&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;in the requires part if you wanted to disable overload resolution when the&lt;br /&gt;
condition fails as in&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;template&amp;lt; typename To, typename From &amp;gt;&lt;br /&gt;
requires // used with enable_if in the declaration part&lt;br /&gt;
is_convertible&amp;lt;From, To&amp;gt;::value&lt;br /&gt;
&amp;amp;&amp;amp; sizeof(To) &amp;gt;= sizeof(From)&lt;br /&gt;
check // included in the function body&lt;br /&gt;
boost::Copyable&amp;lt;From&amp;gt;&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;To&lt;em&gt; memcopy ( To&lt;/em&gt; to, From* from )&lt;br /&gt;
// ...&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Note however that the Concept Copyable from ConceptCheck can not be used in&lt;br /&gt;
the requires clause (I'm looking for), it is not a bool metafunction (or a&lt;br /&gt;
trait). It just compile fail when the parameter doesn't models the concept.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;This makes sense to me and, as far as I can tell, it is also in line&lt;br /&gt;
with Andrzej suggestion. I'm happy to implement it this way.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;CONTRACT_FUNCTION(&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;template( typename To, typename From )&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;requires( // used with enable_if in the declaration part&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;is_convertible&amp;lt;From, To&amp;gt;::value,&lt;br /&gt;
is_convertible&amp;lt;To, From&amp;gt;::value&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;)&lt;br /&gt;
check( // included in the function body&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;static_assert(sizeof(To) &amp;gt;= sizeof(From), "destination too small"),&lt;br /&gt;
boost::Copyable&amp;lt;From&amp;gt;&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;)&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;(To&lt;em&gt;) memcopy ( (To&lt;/em&gt;) to, (From*) from )&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;precondition(&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;to; // pointer not null&lt;br /&gt;
from; // pointer not null&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;)&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;p&gt;) {&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;// ...&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;}&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;I will implement the check clausule now and the require one later and&lt;br /&gt;
only if I'm able to extend the lib to declare and check&lt;br /&gt;
Boost.Generic-like concepts.&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Just to consider all alternatives, we could also do this:&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;CONTRACT_FUNCTION(&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;template( typename To, typename From )&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;if( // used with enable_if in the declaration part&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;is_convertible&amp;lt;From, To&amp;gt;::value,&lt;br /&gt;
is_convertible&amp;lt;To, From&amp;gt;::value&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;)&lt;br /&gt;
requires( // included in the function body&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;static_assert(sizeof(To) &amp;gt;= sizeof(From), "destination too small"),&lt;br /&gt;
boost::Copyable&amp;lt;From&amp;gt;&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;)&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;(To&lt;em&gt;) memcopy ( (To&lt;/em&gt;) to, (From*) from )&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;precondition(&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;to; // pointer not null&lt;br /&gt;
from; // pointer not null&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;)&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/blockquote&gt;
&lt;p&gt;) {&lt;br /&gt;
&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;// ...&lt;br /&gt;
&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;}&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;Given that the 1st clausule is more like enable-if and the 2nd&lt;br /&gt;
clausule states "hard" requirements (in that you get a "hard" compiler&lt;br /&gt;
errors when the requirements are not met). But I'm happy with&lt;br /&gt;
requires/check and if/requires the same way (and I still haven't read&lt;br /&gt;
N3331 which might suggest a syntax vs another...).&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;The requires clausule will be saved for C++11/enable_if/expression-SFINAE/Boost.Generic-like concepts (no hard errors but removal from overload resolution).&lt;br /&gt;
&lt;/p&gt;
&lt;p&gt;static_assert will not be allowed in pre/post/class-inv/block-inv/loop-var/etc but only in the check clausule.&lt;br /&gt;
&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Mon, 10 Sep 2012 18:36:48 -0000</pubDate><guid>https://sourceforge.neteb5f25e971b9ccad9883551aab20bca82f7e2d8b</guid></item><item><title>add an Implementation section</title><link>https://sourceforge.net/p/contractpp/tickets/95/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;Ideally, the docs will provide an Implementation section that can show some example code of what the macros generate. However, given the large amount of generated code this could be hard to do and especially to maintain (if/when the lib impl changes).&lt;br /&gt;
&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Lorenzo Caminiti</dc:creator><pubDate>Mon, 10 Sep 2012 18:21:10 -0000</pubDate><guid>https://sourceforge.net27cf242b3abfdae7cb57c8ee2db0e5f7850ad2ff</guid></item></channel></rss>