I have the following code which defines size_t
equivalent to std::size_t
and ::size_t
if I included <cstddef>
.
// h.hpp
namespace N {
using size_t = decltype(sizeof(int));
}
// a.hpp
#include <h.hpp>
namespace N {
class C {
size_t size() const;
};
void f(size_t);
}
// ^^^ These use N::size_t!
Is this violating the C++ standard in any way and can this cause any bugs in any code that uses both these headers and any other standard header that defines std::size_t
and ::size_t
? I would consider it a bug too if someone couldn't use std::size_t
and N::size_t
interchangably in any context or if using just size_t
in any context would cause any ambiguities.
// someOtherFile.cpp
#include <a.hpp>
#include <cstdint>
namespace N {
// Can there be any problem here? (Inside N::)
}
// Or here? (Outside N::)
My guess would be no because both my and the standard size_t
are just type aliases to unsigned long (long) int