|
Boost Users : |
Subject: Re: [Boost-users] any_cast and added low-level const -> throws
From: nice sw123 (nicesw123_at_[hidden])
Date: 2015-09-23 16:53:43
I was just trying some stuff here..
#include <typeinfo>
#include <cassert>
using T1 = const char *;
using T2 = char *;
assert(typeid(T1) != typeid(T2));
// assert(typeid(const T1) == typeid(const T2));
// -> damn!! seems: cannot add low-level const here
But look at this:
=====
template <typename T>
void func(T t)
{
std::cout << "nonpointer" << std::endl;
}
template <typename T>
void func(T *t)
{
std::cout << "pointer" << std::endl;
}
template <typename T>
void func(const T *t)
{
std::cout << "pointer to const" << std::endl;
}
char str[] = "a1";
func("asdf"); //pointer to const
func(str); // pointer
func(1); // nonpointer
What this tells me is:
if it's not possible to add a low-level const to a typeinfo or
typeindex, then we could still change the constructor of boost::any,
to differentiate between types.
Any comments, hints or pointers welcome.
(You may have noticed... template and meta is not my strength yet...
but I hope to learn)
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