The first thing to check is whether virtual functions are called from constructor.
http://www.artima.com/cppsource/pure_virtual.html
Tuesday, November 09, 2010
Saturday, October 30, 2010
C++ note: static variable from inline member function
I was thinking about Meyers singleton, and wonder how compilers will handle the same static variable defined in difference modules due to inline function expansion. Here are some relevant discussions (it occurs safe not to use the kind of singleton(?)).
http://objectmix.com/c/250462-static-local-variable-inline-static-member-function.html
http://objectmix.com/c/250462-static-local-variable-inline-static-member-function.html
Wednesday, October 13, 2010
Sh note: adding a line at the front of files
The example script adds a new line to the beginning of each file in the directory, recursively, except those files that contain svn.
for file in `find . -type f | grep -v 'svn'`;
do
sed '1i\New line' -i $file
done
for file in `find . -type f | grep -v 'svn'`;
do
sed '1i\New line' -i $file
done
Tuesday, October 12, 2010
Sh note: reversing a file or a line
rev can be used to reverse a line character by character
tac can be used to reverse a file line by line
these two commands are sometimes handy
sh$ rev
abc
cba
sh$ tac
a
b
c^D
c
b
a
echo abcde | rev
a particular context I used tac
ls /corpora/extra/nivre/corpus/conll-x/data/turkish/metu_sabanci/*/*.conll | cut -d '/' -f8-11 | tac
tac can be used to reverse a file line by line
these two commands are sometimes handy
sh$ rev
abc
cba
sh$ tac
a
b
c^D
c
b
a
echo abcde | rev
a particular context I used tac
ls /corpora/extra/nivre/corpus/conll-x/data/turkish/metu_sabanci/*/*.conll | cut -d '/' -f8-11 | tac
Wednesday, March 17, 2010
C++ note: enabling and disabling assert
In C++, assert is by default compiled. To exclude it, the macro NDEBUG must be defined when assert.h is included. This can be done by using -DNDEBUG compiler option or #define NDEBUG in code.
gcc -DNDEBUG -c test.cpp -o test.o
gcc -DNDEBUG -c test.cpp -o test.o
Subscribe to:
Posts (Atom)