Turing machines
March 18, 2008 on 4:37 pm | In .english, coding | No CommentsI was surfing the web and found this blog article on Turing machines, and it mentions this great Turing machine java applet.
New C++ feature: concepts
March 1, 2008 on 2:51 am | In .english, coding | No CommentsThere is a new language feature in C++ going into the upcoming standard, ‘concepts’. If you seriously want to know more about them, there is a google talk about them (There is a google talk index site here and at youtube). Below is the shortest usable example of using concepts. Remember when reading the code: a concept defines which functions and operations a type, used to instantiate a template with, must provide. The code below compiles and runs with ConceptGCC.
// list all operators and functions used in the
// template 'add_t' (below) into concept AddType.
concept AddType<typename T>
{
T::T(const T&);
T operator+(const T&,const T&);
}
template <AddType T> // notice 'AddType' instead of 'typename'
struct add_t
{
// uses the required operator+, and copies
// the result using the copy constructor
T add(const T& a, const T& b) { return a + b; }
};
// an 'int' can do all that's required by AddType...
concept_map AddType<int> {}
int main()
{
add_t<int> x;
int result = x.add(1,2);
return result;
}
As you can see, all this is just a complicated way of writing 1+2, so if you optimize properly, all this boils down to: int main() { return 3; } as it should.
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^
[rss feed: http://blog.superstring.nl/feed/rss/]