/* From C++ Template Metaprogramming Exercise 2.0:
Write a unary metafunction add_const_ref
if it is a reference type, and otherwise returns T const&.
Write a program to test your metafunction. Hint: you can
use boost::is_same to test the results.
*/
#include
#include
#include
#include
#include
using namespace std;
using namespace boost;
template
struct add_const_ref_helper;
template
struct add_const_ref
{
typedef typename
add_const_ref_helper
};
template
struct add_const_ref_helper
{
typedef T type;
};
template
struct add_const_ref_helper
{
typedef T const& type;
};
int main()
{
cout << "Reference: "
<< is_same
<< endl;
cout << "Non-Reference: "
<< is_same
<< endl;
return EXIT_SUCCESS;
}
[/code]