명시적 변환.
- 명시적인 인자 타입을 받고 싶을 때 사용할 수 있다.
- operator bool() 의 경우, 보통 조건문으로 사용하고 싶어서 사용하지만, bool로 변환이 가능 하기 때문에 의도치 않은 연산이 가능 할 수도 있다.
- 이런 문제 때문에 C++11부터 explicit operator bool() 의 형태로 사용할 수 있다.
- explicit(bool) C++20부터 추가.
class Object
{
public:
template<class T>
// explicit를 사용할지 여부를 정할 수 있다. (C++20)
explicit( std::is_integral_v<T> ) Object( T arg )
{
}
}