locales and facets for build in types

Hi, so here is the problem. I wanted to create a facet to read numbers from console input so that those numbers could be both normal unsigned integers and roman numbers. And if I use this facet for my own class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Roman
{
	unsigned val{1};
public:
	Roman() = default;
	Roman(unsigned i) : val{ i } {}

	operator unsigned() { return val; }
};

int main(){
        std::locale loc{std::locale, new Roman_facet};
        std::cin.imbue(loc);

        Roman r;
        std::cin >> r;
st

everything works fine. I'm wondering if there is away to use my facet directly on unsigned int so I could write
1
2
3
4
5
6
7
//...
        std::locale loc{std::locale, new Roman_facet};
        std::cin.imbue(loc);

        unsigned i;
        std::cin >> i;
//... 

and would still be able to input roman numbers and get them transformed into unsigned int's? I kind of feel like there is not a way but still wanted to ask. Haven't read any advanced stuff about this.
Tnx man this will definitely work! :)
Topic archived. No new replies allowed.