Note: It is important to note the difference between the "real time of life" and the "time" that was mentioned when immersed in time complexity. When time complexity is a topic, it is important that no one confuses the use of “time” when “milliseconds have spent something.”
WHAT IS THE DEFINITION OF CONSTANT TIME?
Wikipedia is often considered a bad reference in many contexts, but in this case (and many others) the available definitions are correct and will help describe how everything works.
The article on time complexity talks about constant time:
Wikipedia - Constant time
An algorithm is called constant time (also written as time O (1)) if the value of T (n) is limited to a value that is independent of the size of the input. For example, access to any single element in an array takes constant time, since only one operation is needed to find it.
Since the insert in std::list does not depend on the number of elements in the list, we say that the insert is a constant time; each insertion, regardless of where and when, consists of the same number of elementary operations; none of them are related to the size of the list.
But what if operator new not O(1) ?
Honestly, this does not matter, even if the complexity of new will implicitly depend on the number of previous objects that we allocated, the complexity of our list insertion will not change. The selection is indifferent to the size of the list.
O(1) , constant time, means that the execution time of something is not related to the size of the input in any given algorithm. Even if new not O(1) , our insert is O(1) , because it only describes itself.
The paths used within our list include operator new . The path does not change due to the size of our list, the complexity of the path is a constant time.
So what are we dealing with?
Hannibal_Smith in ##c++ at freenode said something clever and I liked it so much that I will include it in this post: Cost model is a pointing machine.
Although the sentence may be a little misleading, it serves the purpose of explaining how insert O(1) , although parts of the algorithm are not constant time.
The insert in std::list described in terms of the fact that it is a machine that deals only with pointers, and from this point of view it cannot be said that it is nothing but O(1) . The allocation performed inside this algorithm is not related to the complexity of the algorithm itself.