Glas :Re: [glas] Concept C++ [was Re: back to business} |
From: Karl Meerbergen (karl.meerbergen_at_[hidden])
Date: 2006-11-23 09:16:20
Hello,
Here is an example that I find a strong feature that we can use in GLAS:
the function printout() does a conceptwise specialization without the
need for traits or partial template specialization.
Karl
#include <concepts>
#include <iostream>
concept Foo<typename T> {} ;
concept Bar<typename T> {} ;
template <Foo T>
void printout(T const& t) {
std::cout << "concept Foo" << std::endl ;
}
template <Bar T>
void printout(T const& t) {
std::cout << "concept Bar" << std::endl ;
}
concept_map Foo<int> {} ;
concept_map Bar<double> {} ;
int main() {
int i = 5 ;
double d = 6.0 ;
printout( i ) ;
printout( d ) ;
return 0 ;
}