There currently is no way to iterate through a mapping, a mapping isn't a fixed-length array, it simply decodes its input to a certain memory address via a function and retrieves what is contained within it.
There are two alternatives to what you can do.
One would be to create a variable length byte32 array and add any new usernames you would find to it and iterate through the array to cross-reference the input username.
mapping(bytes32 => address) public reserved_names;
bytes32[] public namesInUse;
function create_artist(bytes32 username, string ipfs) {
for (uint i = 0; i < namesInUse.length; i++) {
require(namesInUse[i] != username);
}
reserved_names[username] = msg.sender;
//Rest of your code here
}
This is not the ideal solution because it uses a lot of resources and can lead to an out-of-gas exception if there are many users that sign up to your service.
The efficient way you can solve this is by having a second boolean mapping that is changed to true whenever the username is in use. Because the default value for every boolean mapping is false you won't face any issues. An example implementation can be found below.
mapping(bytes32 => address) public reserved_names;
mapping(bytes32 => bool) public namesInUse;
function create_artist(bytes32 username, string ipfs) {
require(!namesInUse[username]);
reserved_names[username] = msg.sender;
namesInUSe[username] = true;
//Rest of your code here
}
EDIT:
Nikita's answer is much more gas efficient and won't consume any memory at all. What he is taking advantage of is that address variables when initiated point to the 0x0000000000000000000000000000000000000000 address which can be shorthanded to 0x0, not 0x as his answer dictates.