|
Boost Users : |
From: Bruce Trask (Bruce.Trask_at_[hidden])
Date: 2005-04-01 08:36:10
Hi David,
Thanks for you response.
On Thu, 2005-03-31 at 14:51 -0500, David Abrahams wrote:
> char const test_string[] = "TestStringName";
>
> A pointer or reference to test_string can be used as a template
> parameter as long as test_string is declared at namespace scope.
>
Right. Something like what's on page 41 of Vandevoorde and Josuttis?
Something like
#include <iostream>
using namespace std;
extern char const test_string[] = "TestStringName";
template<char const* name>
class MyClass
{
public:
static std::string rep()
{
return name;
}
};
int main()
{
cout << MyClass<test_string>::rep() << endl;
return 0;
}
Dumb question and just so I am clear: when you say "declared at
namespace scope" are you referring to the "external linkage" that David
and Nicolai are referring to which keeps two string literals with the
same value being the same object?
Thanks,
Bruce
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net