Where is defined static_cast casting rules?

Hello.

Code below casts int 10 to vector of size 10. But where are defined such casting rules?

Is it possible to find in c++ documentation such casting rules?

 
std::vector<int> v = static_cast<std::vector<int>>(10);
The cast effectively says:
"construct a std::vector<int> object and initialize it with value 10"

The 10 is an int and ints don't have custom conversion operators. Custom types could have.

Therefore, whe have to ask, how does one construct a std::vector?
The answer is the constructors: http://www.cplusplus.com/reference/vector/vector/vector/

Which of them does match best a single integer?

The answer is the fill constructor:
explicit vector (size_type n, const allocator_type& alloc = allocator_type());
The standard defines the precise rules. Draft IS: http://eel.is/c++draft/expr.static.cast

However,
The standard is not intended to teach how to use C++. Rather, it is an international treaty – a formal, legal, and sometimes mind-numbingly detailed technical document intended primarily for people writing C++ compilers and standard library implementations. https://isocpp.org/std/the-standard


The documentation in cppreference.com would be more accessible:
http://en.cppreference.com/w/cpp/language/static_cast


A dumbed down explanation, which would be less intimidating (and therefore, perhaps more pragmatic) to people who are quite new to C++ is available on this site.
see the topic static_cast under: http://www.cplusplus.com/doc/tutorial/typecasting/
Topic archived. No new replies allowed.