A doping-free approach to carbon nanotube electronics and optoelectronics