This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [patch]: Removing duplicate functions, part 3 (and brief copyrightquestion)
Nathan Myers wrote:
On Mon, Feb 14, 2005 at 02:32:01PM +0100, Paolo Carlini wrote:
Chris Jefferson wrote:
On a different note, are there offical guidelines on copying code?
I've been writing a (very small, very limited) preprocessor library so
I can macroise <tuple>, after a week of fun I had managed to create
all the functionality I needed except for an O(1) equality testing
macro. I knew that boost had one, so I decided to go and have a look
to see how they did it. However now I've seen the "trick", I can't
think of any other real way of implementing it than basically exactly
the same code line-for-line...
Eh, this is a mine field, in general, but with boost things should be
easy. Why don't you contact directly the author of that code, while
waiting for feedbacks?!?
The Boost license specifically allows importing its code, but you would
need to incorporate their copyright notice too. The author might allow
a less intrusive inclusion, such as "thanks to Joe for ...", or even
less.
Thats true, although of course the copyright would also have to be
signed over. Hopefully that won't be too hard.
Legally, if there's really only one reasonable way to express a
technical idea, then it is not covered by copyright. As Paolo notes,
though, that may be hard to prove for the case of anything complicated;
it might just be one's own lack of imagination.
Thats more than possible :)
If anyone would like to take up the challenge, it is to write a macro
which takes two parameters which are both integers in some fixed range
and returns 1 if they are identical, 0 if they aren't.
For example, a file containing
_GLIBCXX_PRE_EQUAL(0,1) _GLIBCXX_PRE_EQUAL(1,1) _GLIBCXX_PRE_EQUAL(2,4)
would become
0 1 0
after preprocessing.
Note your macro is quite welcome to output any old rubbish if given
something like:
_GLIBCXX_PRE_EQUAL(2,1+1)
It is possible to do this in O(n) by writing a macro which just tests if
a value is zero, and then use a while loop to keep decreasing both terms
until either only one becomes zero (then it's false) or they both become
equal (then it's true). However it would be nice to have an O(1)
implementation. I should warn however that doing so requires (I believe)
some knowledge of what the prepropressor does (and doesn't) do.
Chris