Skip to content

Instantly share code, notes, and snippets.

@yifu
Created September 21, 2012 15:10
Show Gist options
  • Select an option

  • Save yifu/3762070 to your computer and use it in GitHub Desktop.

Select an option

Save yifu/3762070 to your computer and use it in GitHub Desktop.
#include <iostream>
template <int length>
int foo( const char tab[length] )
{
return sizeof( length );
}
template <size_t N>
//int bar( const char tab[N] )
int bar( const char (&tab)[N] )
{
return sizeof( tab );
}
int main()
{
std::cout << "hello world" << std::endl;
char test[11];
std::cout << "length = " << bar( test ) << std::endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment